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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b1a1ed8b075945 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Allocators and exceptions => Read Me First Reply-To: anon@anon.org (anon) References: <1189323618.588340.87180@o80g2000hse.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Mon, 10 Sep 2007 10:37:40 GMT NNTP-Posting-Host: 12.65.132.193 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1189420660 12.65.132.193 (Mon, 10 Sep 2007 10:37:40 GMT) NNTP-Posting-Date: Mon, 10 Sep 2007 10:37:40 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:1856 Date: 2007-09-10T10:37:40+00:00 List-Id: It is there, but it is in a hard section to see. Took me a little time to find it. And you can discard the early post. And no, it is not truly guarantee, but some compiler may reclain immediate during a raised exception. But to Force it use: pragma Restrictions ( Immediate_Reclamation ) ; Note: RM Annex H => H.4 Safety and Security Restrictions pragma Restrictions ( Immediate_Reclamation ) ; with Ada.Text_IO ; with Ada.Integer_Text_IO ; -- procedure test is type ap is access positive ; Value : ap ; Minus5 : integer := -5 ; begin -- -- FIRST: name is give a location and initial value -- Value := new Positive'( 512 ); Ada.Text_IO.Put_Line ( "Inital" ) ; Ada.Text_IO.Put ( " Value = " ) ; Ada.Integer_Text_IO.Put ( Value.all ) ; Ada.Text_IO.New_Line ; begin Value := new Positive'( Minus5 ) ; Ada.Text_IO.Put_Line ( "Value = a new constant" ) ; exception when Storage_Error => Ada.Text_IO.Put_Line ( "Storage Error" ) ; when Constraint_Error => Ada.Text_IO.Put_Line ( "Constraint Error" ) ; end ; -- -- The point Value is still points to a valid location -- Ada.Text_IO.Put ( " Value = " ) ; Ada.Integer_Text_IO.Put ( Value.all ) ; Ada.Text_IO.New_Line ; end test ; In <1189323618.588340.87180@o80g2000hse.googlegroups.com>, Maciej Sobczak writes: >What happens when during the initialization of the newly allocated >object an exception is raised? > >I cannot find anything in the AARM that covers this case. What I want >to find exactly is the *guarantee* that the allocated memory is >automatically reclaimed. >Any relevant paragraph numbers are highly welcome. > >-- >Maciej Sobczak >http://www.msobczak.com/ >