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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7a3b1c6915ea1273,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.211.195 with SMTP id ne3mr202877pbc.2.1326410813881; Thu, 12 Jan 2012 15:26:53 -0800 (PST) Path: lh20ni175393pbb.0!nntp.google.com!news2.google.com!postnews.google.com!z1g2000vbx.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: How many Ada compiler bugs are here? Date: Thu, 12 Jan 2012 15:20:22 -0800 (PST) Organization: http://groups.google.com Message-ID: <01dd6341-9c3c-4dcb-90f8-6ac66c65eb66@z1g2000vbx.googlegroups.com> NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 X-Trace: posting.google.com 1326410813 8496 127.0.0.1 (12 Jan 2012 23:26:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 12 Jan 2012 23:26:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z1g2000vbx.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-01-12T15:20:22-08:00 List-Id: Consider: with Ada.Finalization; with Ada.Text_IO; procedure Test is package P is Some_Error : exception; type T (<>) is limited private; function Make_T return T; private type T is new Ada.Finalization.Limited_Controlled with record Initialized : Boolean := False; end record; overriding procedure Adjust (V : in out T); overriding procedure Finalize (V : in out T); end P; package body P is function Make_T return T is begin raise Some_Error; -- needed to please the compiler: return (Ada.Finalization.Limited_Controlled with others => <>); end Make_T; procedure Adjust (V : in out T) is begin Ada.Text_IO.Put_Line ("adjusting"); end Adjust; procedure Finalize (V : in out T) is begin Ada.Text_IO.Put_Line ("finalizing with Initialized =" & Boolean'Image (V.Initialized)); end Finalize; end P; begin declare Tmp : P.T := P.Make_T; begin null; end; exception when others => Ada.Text_IO.Put_Line ("exception handled"); end Test; This program prints (GNAT 2011): $ ./test finalizing with Initialized =TRUE exception handled $ Above: 1. Adjust should not be allowed to be declared (it is a *limited* type). But I have defined it to trace the remaining bugs: 2. The return statement in Make_T should not be required, because it is unreachable anyway. 3. Logically, Tmp is never created, because Make_T raises an exception. Somehow some object is finalized. Apparently it is Tmp, which should not exist. 4. Somehow Tmp.initialized = True, even though its default value is defined to be False. Guess how I found that out. It's past midnight here... Are there any known workarounds? -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com