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: a07f3367d7,65b902127ca8a604 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!feeder.erje.net!newsfeed.straub-nv.de!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Issue with GNAT GPL 2009 and GtkAda Date: Fri, 26 Jun 2009 16:40:58 -0500 Organization: Jacob Sparre Andersen Message-ID: References: <4A414EBB.8060204@free.fr> <1avd65rn49abv$.krcxo2gdzb16$.dlg@40tude.net> <7ajfrgF1vdsnlU1@mid.individual.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1246052500 16023 69.95.181.76 (26 Jun 2009 21:41:40 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 26 Jun 2009 21:41:40 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Original Xref: g2news2.google.com comp.lang.ada:6654 Date: 2009-06-26T16:40:58-05:00 List-Id: "Alex R. Mosteo" wrote in message news:7ajfrgF1vdsnlU1@mid.individual.net... ... >> declare >> Ptr : access T := new T; >> begin >> ... >> External_Ptr := Ptr.all'Uchecked_Access; -- Copy the pointer >> ... >> end; -- Now External_Ptr is dangling, because the object is freed. > > If I understand correctly, this is because the type of Ptr goes out of > scope? > > I strongly suspect that Gnat does not behave this way, but I should test > it. Gnat would be wrong if it does *not* behave this way. (Janus/Ada has this bug currently.) The master of the anonymous access type is the declare block, and it has to be finalized at the end of the scope. I suppose you could leave the memory around, but the object has to be finalized (as Dmitry's example shows). Randy.