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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2866100c9a2b8ce7 X-Google-Attributes: gid103376,public From: Jonas Nygren Subject: Re: Free'ing extended types Date: 1996/04/28 Message-ID: <3183AC75.335C@ehs.ericsson.se>#1/1 X-Deja-AN: 151898242 content-type: text/plain; charset=us-ascii organization: Ericsson Hewlett-Packard Telecommunications AB mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01Gold (WinNT; I) Date: 1996-04-28T00:00:00+00:00 List-Id: 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).