comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Limited_Controlled types as 'out' arguments
Date: Thu, 31 Jul 2003 12:51:46 -0500
Date: 2003-07-31T12:51:46-05:00	[thread overview]
Message-ID: <viilmao1p7ib40@corp.supernews.com> (raw)
In-Reply-To: slrnbihtb3.2j7.lutz@taranis.iks-jena.de

"Lutz Donnerhacke" <lutz@iks-jena.de> wrote in message
news:slrnbihtb3.2j7.lutz@taranis.iks-jena.de...
...
> Results in:
> Initializing 134630800(0)
> Initializing 134630816(1)
> Setting from 134630816(1)
> Setting o1   134630800(0)
> Setting o2   134630800(0)
> Finalizing   134630800(0)
> raised PROGRAM_ERROR : t1.adb:14
> Finalizing   134630816(1)
>
> I'am mad?

Yes. :-)

Finalize routines always have to be written to work on an already finalized
object. There are variety of ways for extra Finalize calls to occur even
without any explicit ones. So your Finalize needs to be something like:

   procedure Finalize(o : in out Test) is
   begin
      if o.a /= null then
        Debug("Finalizing  ", o.a);
        Free(o.a);
      -- else already finalized.
      end if;
   end Finalize;

Otherwise, you're freeing an already freed object. This is discussed in the
AARM:
    http://www.adaic.org/standards/95aarm/html/AA-7-6-1.html
See the note at paragraph 24 and the following discussion.

                        Randy.






  parent reply	other threads:[~2003-07-31 17:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-30 11:31 Limited_Controlled types as 'out' arguments Lutz Donnerhacke
2003-07-30 12:22 ` Dmitry A. Kazakov
2003-07-30 12:32   ` Lutz Donnerhacke
2003-07-30 14:24     ` Dmitry A. Kazakov
2003-07-30 14:25       ` Lutz Donnerhacke
2003-07-30 14:48         ` Dmitry A. Kazakov
2003-07-30 15:15           ` Lutz Donnerhacke
2003-07-31 10:26             ` Dmitry A. Kazakov
2003-07-31 10:54               ` Lutz Donnerhacke
2003-07-31 11:50                 ` Dmitry A. Kazakov
2003-07-31 12:19                   ` Lutz Donnerhacke
2003-07-31 13:15                     ` Dmitry A. Kazakov
2003-07-31 17:51                 ` Randy Brukardt [this message]
2003-07-30 15:01         ` Vinzent Hoefler
2003-07-30 15:16           ` Lutz Donnerhacke
2003-07-30 15:52         ` Lutz Donnerhacke
2003-07-30 19:30           ` Randy Brukardt
2003-07-31  7:43             ` Lutz Donnerhacke
2003-07-30 12:31 ` Matthew Heaney
2003-07-30 12:57   ` Lutz Donnerhacke
2003-07-30 13:47     ` Martin Dowie
2003-07-30 17:06     ` Matthew Heaney
2003-07-30 12:37 ` Martin Dowie
2003-07-30 12:59   ` Lutz Donnerhacke
2003-07-30 13:41     ` Martin Dowie
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox