From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee06257af909a235 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!out03b.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!newsfeed.yul.equant.net!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Finalization of static package variables Date: Fri, 11 May 2007 14:26:37 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4640f20b$1@news.upm.es> <4642493f@news.upm.es> <4644b24e$1@news.upm.es> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1178907997 16092 192.74.137.71 (11 May 2007 18:26:37 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 11 May 2007 18:26:37 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:a/QQR4xdWhbjUrXUs7Lg9aPLtYI= Xref: g2news1.google.com comp.lang.ada:15766 Date: 2007-05-11T14:26:37-04:00 List-Id: Manuel Collado writes: > But an access variable can refer to a static variable. Is the following > Ada95 code schema legal? It is erroneous, which is the Ada term for "wrong, and will cause totally unpredictable behavior at run time." Most likely, you will corrupt the heap data structures if you try to free objects that are not heap allocated. Note that if you erase the "Dispose", then Edit will be finalized when program is done. >...What about Ada200x (or just Ada, if you want)? Same answer. > It seems to work in GNAT-3.15p (it lets finalize 'Edit'), but ... > > ------------------------------------------------- > package body View_Editor is > > Edit: aliased Dialog_Type := > Dialog (420, 350, "Conversion Rates", 'Q', Main_Font); > > [...snipped...] > > procedure Editor_Destroy is > type Dialog_Access is access all Dialog_Type; > procedure Dispose is > new Ada.Unchecked_Deallocation ( > Object => Dialog_Type, > Name => Dialog_Access ); > Pointer: Dialog_Access := Edit'access; > begin > Dispose (Pointer); > end Editor_Destroy; > > end View_Editor; - Bob