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,68536605ede13a20 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.190.71 with SMTP id go7mr69318pbc.8.1324340191326; Mon, 19 Dec 2011 16:16:31 -0800 (PST) Path: lh20ni42202pbb.0!nntp.google.com!news2.google.com!postnews.google.com!q9g2000yqe.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: GNAT - return by anonymous access Date: Mon, 19 Dec 2011 16:14:34 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <784c67eb-a542-41b0-b23d-fca1234e56b2@n10g2000vbg.googlegroups.com> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 X-Trace: posting.google.com 1324340191 16911 127.0.0.1 (20 Dec 2011 00:16:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 20 Dec 2011 00:16:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q9g2000yqe.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-19T16:14:34-08:00 List-Id: On Dec 19, 5:46=A0pm, "Randy Brukardt" wrote: > "Simon Belmont" wrote in message > > news:784c67eb-a542-41b0-b23d-fca1234e56b2@n10g2000vbg.googlegroups.com... > > > > > This ostensibly simple program prints strange results... > ... > > =A0 type test_type (p_obj : access Integer) is limited null record; > ... > > =A0 function get return test_type is > > =A0 begin > > =A0 =A0 =A0return test_type'(p_obj =3D> new Integer'(42)); > > =A0 end get; > > You are creating a coextension here. The *language rules* for coextension= s > are full of bugs; we're fixing them virtually every ARG meeting. There is > little hope for a compiler to get these right in the face of that, beyond > which doing so is quite expensive. > > IMHO, any use of an allocator for an anonymous access type is asking for > trouble. There is no way to free the memory for such things, and the > lifetime can easily be extended in various ways, so if the compiler tries > using a properly local pool for the allocator you end up with a dangling > poiner. Moreover, they appear to promise something that they cannot deliv= er > (heap-based allocation). > > Ada 2012 has a restriction No_Anonymous_Allocators; I recommend that all = Ada > programs include and obey this restriction. (Janus/Ada does this by defau= lt, > because we never attempted to use the local pools that supposedly are > required, and it is better to reject a program rather than implement it > "wrong".) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Randy. Hm, so then are local pools useless? Or do they have their place? I read some of the rational[e/ization] for them and it seems reasonable, but I've not actually used them.