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-Thread: 103376,6b1a1ed8b075945 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Allocators and exceptions References: <1189323618.588340.87180@o80g2000hse.googlegroups.com> <1189524788.300591.312380@w3g2000hsg.googlegroups.com> <1189547814.740732.220140@x40g2000prg.googlegroups.com> In-Reply-To: <1189547814.740732.220140@x40g2000prg.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <%tGFi.80362$Xa3.20645@attbi_s22> NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1189557243 12.201.97.213 (Wed, 12 Sep 2007 00:34:03 GMT) NNTP-Posting-Date: Wed, 12 Sep 2007 00:34:03 GMT Organization: AT&T ASP.att.net Date: Wed, 12 Sep 2007 00:34:03 GMT Xref: g2news2.google.com comp.lang.ada:1897 Date: 2007-09-12T00:34:03+00:00 List-Id: Adam Beneschan wrote: > > OK, I think I have one. GNAT compiles and runs it, although I haven't > checked the language rules carefully to make sure it's legal. It looks legal to me. I've added a little test to see what's happening with P: package Pak1 is type Rec1 is limited private; type Rec1_Acc is access all Rec1; function Func1 (R : Rec1_Acc) return Integer; procedure Check_P; private type Rec1 is limited record F1 : Integer := 123; F2 : Integer := Func1 (Rec1'Unchecked_Access); end record; end Pak1; with Ada.Text_IO; package body Pak1 is P : Rec1_Acc; function Func1 (R : Rec1_Acc) return Integer is begin P := R; if R.F1 > 100 then raise Constraint_Error; end if; return 1; end Func1; procedure Check_P is -- null; begin -- Check_P Ada.Text_IO.Put_Line (Item => "P = null => " & Boolean'Image (P = null) ); if P /= null then Ada.Text_IO.Put_Line (Item => Integer'Image (P.F1) ); end if; end Check_P; end Pak1; with Pak1; procedure Test84 is -- null; begin Create : declare X : Pak1.Rec1_Acc := new Pak1.Rec1; begin -- Create null; end Create; exception -- Test84 when others => Pak1.Check_P; end Test84; and get output: P = null => FALSE 123 I suppose P could be dangling, with the memory it points to not yet reused, but I suspect that is not the case. -- Jeff Carter "C++ is like jamming a helicopter inside a Miata and expecting some sort of improvement." Drew Olbrich 51