From: Jonas Nygren <ehsjony@ehs.ericsson.se>
Subject: Re: Free'ing extended types
Date: 1996/04/28
Date: 1996-04-28T00:00:00+00:00 [thread overview]
Message-ID: <3183AC75.335C@ehs.ericsson.se> (raw)
I forward this on the request of Laurent.
: Laurent Guerby wrote:
: > Jonas Nygren writes
: > : I read the following in the RM on unchecked_deallocation:
: > :
: > : 13.11.2(16)
: > : .... 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.
[deleted]
: Sorry, I got my example code wrong, it should have been:
:
: procedure free is new unchecked_deallocation(a'Class,
ap);
:
: 13.11.2(16) talks about 'erroneous execution', i.e. an error
which the
: compiler can/need not detect. In the example 'p' is a pointer
to a'class
: and when the call to free is made it actually points to an
instance of
: type 'b'. So the question is, could this be considered an
erroneous
: execution?
I *think* that it (erroneous/not erroneous) is
implementation
dependant, because for each access type the Storage_Pool
(if not
user-specified) is choosen "in an implementation-defined
manner", see
13.11(17). This has to be documented for each compiler. In the
case of
GNAT, here is the code for Unchecked_Deallocation :
with System;
procedure Unchecked_Deallocation (X : in out Name) is
procedure Free (A : System.Address);
pragma Import (C, Free);
begin
if X /= null then
Free (X.all'Address);
X := null;
end if;
end Unchecked_Deallocation;
So there's nothing that could lead to an erroneous execution
(note
the X.all'access, the libc then does what's needed).
: /jonas
PS: this is of general interest, please post your correction
and my
answer to comp.lang.ada for verification (legality stuff and
GNAT
stuff) for me, my news server is down this week-end. Thank you.
--
-- Laurent Guerby, student at Telecom Bretagne (France), Team
Ada.
-- "Use the Source, Luke. The Source will be with you, always
(GPL)."
-- http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project).
-- Try GNAT, the GNU Ada 95 compiler
(ftp://cs.nyu.edu/pub/gnat).
next reply other threads:[~1996-04-28 0:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-28 0:00 Jonas Nygren [this message]
1996-04-28 0:00 ` Free'ing extended types Robert Dewar
1996-04-29 0:00 ` Jonas Nygren
1996-04-29 0:00 ` Robert A Duff
1996-04-29 0:00 ` Jonas Nygren
1996-04-29 0:00 ` Robert Dewar
1996-04-29 0:00 ` Robert A Duff
1996-05-20 0:00 ` Type conversion between access types (was: Free'ing extended types) Scott Leschke
1996-05-21 0:00 ` Dale Stanbrough
1996-05-21 0:00 ` Robert A Duff
1996-05-21 0:00 ` Robert A Duff
1996-05-22 0:00 ` Scott Leschke
1996-05-23 0:00 ` Robert A Duff
1996-05-23 0:00 ` progers
1996-05-24 0:00 ` Scott Leschke
1996-05-24 0:00 ` Robert A Duff
1996-04-29 0:00 ` Free'ing extended types Laurent Guerby
1996-04-29 0:00 ` Robert A Duff
1996-04-29 0:00 ` Laurent Guerby
1996-04-29 0:00 ` Robert A Duff
1996-04-29 0:00 ` Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
1996-04-26 0:00 Jonas Nygren
1996-04-26 0:00 ` Laurent Guerby
1996-04-27 0:00 ` Jerry van Dijk
1996-04-28 0:00 ` Robert Dewar
1996-04-28 0:00 ` Jonas Nygren
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox