comp.lang.ada
 help / color / mirror / Atom feed
From: Jonas Nygren <ehsjony@ehs.ericsson.se>
Subject: Re: Free'ing extended types
Date: 1996/04/29
Date: 1996-04-29T00:00:00+00:00	[thread overview]
Message-ID: <3184803D.1208@ehs.ericsson.se> (raw)
In-Reply-To: dewar.830716817@schonberg


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




  parent reply	other threads:[~1996-04-29  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-28  0:00 Free'ing extended types Jonas Nygren
1996-04-28  0:00 ` Robert Dewar
1996-04-29  0:00   ` Laurent Guerby
1996-04-29  0:00     ` Robert A Duff
1996-04-29  0:00       ` Robert Dewar
1996-04-29  0:00   ` Laurent Guerby
1996-04-29  0:00     ` Robert A Duff
1996-04-29  0:00   ` Jonas Nygren [this message]
1996-04-29  0:00     ` Robert A Duff
1996-04-29  0:00       ` Robert Dewar
1996-04-29  0:00         ` Robert A Duff
1996-04-29  0:00       ` Jonas Nygren
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
  -- strict thread matches above, loose matches on Subject: below --
1996-04-26  0:00 Free'ing extended types 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