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,f0be8eebb2993001 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!f18g2000yqd.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada 2012 : aliased parameters ? Date: Tue, 29 Mar 2011 00:34:49 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301384089 1667 127.0.0.1 (29 Mar 2011 07:34:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 29 Mar 2011 07:34:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: f18g2000yqd.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 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) Xref: g2news1.google.com comp.lang.ada:18573 Date: 2011-03-29T00:34:49-07:00 List-Id: On 29 Mar, 05:16, "Randy Brukardt" wrote: > The motivating case is to make the containers better. Ada 2012 adds the > following to all of the containers: > > =A0 =A0 function Reference (Container : aliased in out Vector; Position := in > Cursor) > =A0 =A0 =A0 =A0return Reference_Type; Out of curiosity - is it possible to leak the reference this way? I mean - is it possible for the caller to make a copy of returned reference and store it arbitrarily long? Note that the "copy" might not be obvious, as in: declare My_Element : Vector_Type.Reference_Type renames My_Vector.Reference (My_Cursor); begin My_Element.Comp :=3D 10; My_Element.Other_Comp :=3D 3.14; end; The C++ equivalent of this is both a fantastic performance feature and a deadly security hole. How is this solved in Ada? -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com