comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Finalization of static package variables
Date: Fri, 11 May 2007 14:26:37 -0400
Date: 2007-05-11T14:26:37-04:00	[thread overview]
Message-ID: <wccfy6343oi.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 4644b24e$1@news.upm.es

Manuel Collado <m.collado@lml.ls.fi.upm.es> 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



  reply	other threads:[~2007-05-11 18:26 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
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 [this message]
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