From: Manuel Collado <m.collado@lml.ls.fi.upm.es>
Subject: Re: Finalization of static package variables
Date: Thu, 10 May 2007 00:19:26 +0200
Date: 2007-05-10T00:19:26+02:00 [thread overview]
Message-ID: <4642493f@news.upm.es> (raw)
In-Reply-To: <uwszio1b7.fsf@stephe-leake.org>
Stephen Leake escribi�:
> Manuel Collado <m.collado@lml.ls.fi.upm.es> 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
next prev parent reply other threads:[~2007-05-09 22:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-08 21:55 Finalization of static package variables Manuel Collado
2007-05-09 8:13 ` Alex R. Mosteo
2007-05-09 8:20 ` Stephen Leake
2007-05-09 15:15 ` Adam Beneschan
2007-05-09 16:01 ` Markus E Leypold
2007-05-09 22:00 ` Manuel Collado
2007-05-09 23:27 ` Adam Beneschan
2007-05-10 4:52 ` Jeffrey R. Carter
2007-05-16 0:41 ` Randy Brukardt
2007-05-10 8:16 ` Alex R. Mosteo
2007-05-16 0:36 ` Randy Brukardt
2007-05-16 14:06 ` Adam Beneschan
2007-05-16 16:47 ` Jeffrey R. Carter
2007-05-16 19:10 ` Randy Brukardt
2007-05-22 4:41 ` christoph.grein
2007-05-22 6:25 ` tmoran
2007-05-22 22:19 ` Randy Brukardt
2007-05-10 10:57 ` Stephen Leake
2007-05-09 22:19 ` Manuel Collado [this message]
2007-05-10 5:38 ` AW: " Grein, Christoph (Fa. ESG)
2007-05-10 10:55 ` Stephen Leake
2007-05-11 18:12 ` Manuel Collado
2007-05-11 18:26 ` Robert A Duff
2007-05-12 19:17 ` Finalization of static package variables - summary Manuel Collado
2007-05-16 0:49 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox