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 Date: Thu, 10 May 2007 00:19:26 +0200 From: Manuel Collado User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Finalization of static package variables References: <4640f20b$1@news.upm.es> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 138.100.242.205 Message-ID: <4642493f@news.upm.es> X-Trace: news.upm.es 1178749247 138.100.242.205 (10 May 2007 00:20:47 +0200) Path: g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder5.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!62.216.30.27.MISMATCH!newsgate.cistron.nl!xs4all!aotearoa.belnet.be!news.belnet.be!news.rediris.es!news.upm.es!not-for-mail Xref: g2news1.google.com comp.lang.ada:15698 Date: 2007-05-10T00:19:26+02:00 List-Id: Stephen Leake escribi�: > Manuel Collado writes: > >> Variables declared in the global scope of a package body seem not to >> be finalized automatically at the end of the whole program (using GNAT >> 3.15p on WindowsXP). > [...] >> After several trial-and-error attemps, an Unchecked_Deallocation on >> these variables seems to do the trick (the whole program terminates >> smoothly). > > Unchecked_Deallocation is used on access variables (aka "pointers"). > Such variables are _not_ automatically finalized by Ada; calling > Unchecked_Deallocation is the standard-compliant way to finalize them. > >> But this is probably not standard-conformant (ARM 13.11.2-16). > > This paragraph says: > > Evaluating a name that denotes a nonexistent object is erroneous. > The execution of a call to an instance of Unchecked_Deallocation > is erroneous if the object was created other than by an allocator > for an access type whose pool is Name'Storage_Pool. > > I don't see how that is relevant to your problem. "... erroneous ... if the object was created other than by an allocator for an access type whose pool is Name'Storage_Pool." Are static package variables allocated in this pool? > > What version of the ARM are you quoting? When you say "ARM" without a > year, it implies "current" which means "Ada 2007" (or, informally, > "Ada 2005"). Doesn't "using GNAT 3.15p" give you any hint :-) ? > [...] > Posting code that outlines what you are doing would help a lot. ------------------------------------ package body Pkg_Dialog is My_Dialog: aliased Dialog_Type := Dialog (200, 100, "Dialog 3", 'Q'); ... procedure Do_Dialog is begin ... exercise My_Dialog ... declare type Dialog_Access is access all Dialog_Type; procedure Dispose is new Ada.Unchecked_Deallocation ( Object => Dialog_Type, Name => Dialog_Access ); Pointer: Dialog_Access := My_Dialog'access; begin Dispose (Pointer); -- force My_Dialog finalization end; end Do_Dialog; end Pkg_Dialog; ----------------------------------- Regards. -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado