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/29 Message-ID: <3184803D.1208@ehs.ericsson.se>#1/1 X-Deja-AN: 152006356 references: <3183AC75.335C@ehs.ericsson.se> 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-29T00:00:00+00:00 List-Id: Robert Dewar wrote: > > Jonas said > > " So there's nothing that could lead to an erroneous execution > (note > the X.all'access, the libc then does what's needed)." I think the above quote is from Laurent Guerby. > > You seem to have the wrong idea of what erroneous is about. An erroneous > execution is one whose semantics is not specified by the reference > manual. You seem to think this means that it wlil blow up or do > something wrong. Not at all! It *may* blow up but it does not have to! Murphy's law: If it can blow up - it will blow up. I personally take a very simplistic approach to never use a construct that I know can blow up. > > You can look at the execution of a particular impementation and conclude > that a particular erroneous execution will have no ill effect on that > implementation, but that does not mean that the exeution is not erroneous! Well, I am aiming for portable code and free'ing memory can have great effect on the program structure. I don't want to have to rewrite my code between different language implementations. > > This is one of these places where no amount of testing can help, only > a detailed knowledge of the formal semantics of the refrence manual > can tell you if a given execution is indeed erroneous -- it is not something > you can (necessarily) observe. That is what my original question was all about. A pity you did not have an anwer to that - I guess you have the "detailed knowledge of the formal semantics" of Ada to respond to my question. I repeat my original question here: with Ada.Unchecked_Deallocation; procedure St is type a is tagged record X : Integer; end record; type ap is access all a'class; procedure free is new Ada.unchecked_deallocation(A'class, ap); type b is new a with record Y : Integer; end record; -- a is extended p : ap := new b; begin free(p); -- erroneous ?? end St; Could the call on free result in erroneous execution (in any conceivable law abiding implementation of Ada). /jonas