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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b2dd3ff35d68d825 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-10 04:37:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.vmunix.org!fu-berlin.de!uni-berlin.de!82-43-33-254.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Unchecked_Deallocation subtleties Date: Thu, 10 Apr 2003 12:37:19 +0100 Organization: ThoughtWing Computer Software Message-ID: References: <87smssj94u.fsf@inf.enst.fr> <3E94502E.6070108@cogeco.ca> <87llyj5p0s.fsf@inf.enst.fr> NNTP-Posting-Host: 82-43-33-254.cable.ubr01.croy.blueyonder.co.uk (82.43.33.254) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed X-Trace: fu-berlin.de 1049974632 11163049 82.43.33.254 (16 [25716]) In-Reply-To: <87llyj5p0s.fsf@inf.enst.fr> User-Agent: Opera7.03/Win32 M2 build 2670 Xref: archiver1.google.com comp.lang.ada:36042 Date: 2003-04-10T12:37:19+01:00 List-Id: On Wed, 09 Apr 2003 23:39:31 +0200, Samuel Tardieu wrote: >>>>>> "Nick" == Nick Roberts writes: > > Nick> Consider the following example skeleton piece of code: > > Nick> declare > Nick> X: Some_Access_Type; > Nick> begin > Nick> ... -- [1] > Nick> Y := X.all; -- [2] last use of X > Nick> ... -- [3] > Nick> Free(X); -- [4] > Nick> end; > > Nick> Although it may be that no compiler would (or even could) do so > Nick> in practice, other rules in the ARM made it theoretically > Nick> possible for the implementation to automatically reclaim the > Nick> storage occupied by whatever X pointed to (assuming no other > Nick> access value pointed to it) at any point in the elided code > Nick> section [3]. > > I would say that Free(X) is certainly a use of X, so the last use of X > is not in [2], it is in [4]. Hmmmm. Obviously you are right, Sam, on the face of it. Theoretically (there's that word again), a compiler could apply a special rule to an instance of Unchecked_Deallocation (that, for each call, the object pased to it is not considered to have been used), on the basis that this would never do any harm and might provide opportunities for earlier automatic storage reclamation. In practice I doubt any compiler has ever actually done this. Furthermore (on going back to the manuals), I note that Ada allows the Controlled pragma to be applied to an access type to instruct the compiler not to perform automatic storage reclamation, although neither the Ada 83 nor the Ada 95 standards made it requisite to apply this pragma to an access type for which Unchecked_Deallocation is also used. So, I'm trying to point out my guess as to the thought processes of the Ada 83 (Green) design team, despite the fact that it all turned out to be a bit theoretical. -- Nick Roberts Jabber: debater@charente.de [ICQ: 159718630]