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-Received: by 2002:ac8:4e0d:: with SMTP id c13mr10191241qtw.0.1588789681449; Wed, 06 May 2020 11:28:01 -0700 (PDT) X-Received: by 2002:aca:230c:: with SMTP id e12mr3572294oie.78.1588789681158; Wed, 06 May 2020 11:28:01 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 6 May 2020 11:28:00 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1e054635-6c0a-41ca-8cc2-080aa5f532a3@googlegroups.com> Subject: Re: How can one record component be local and another not? From: Jere Injection-Date: Wed, 06 May 2020 18:28:01 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:58615 Date: 2020-05-06T11:28:00-07:00 List-Id: On Wednesday, May 6, 2020 at 1:30:58 PM UTC-4, Niklas Holsti wrote: > On 2020-05-05 20:32, hreba wrote: > > Ok, with all your hints I came to the following solution: > >=20 > > --=20 > > package Aux is > > =C2=A0=C2=A0 type Integer_P is access all Integer; > > =C2=A0=C2=A0 type Rec is limited record > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 a: aliased Integer; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p: Integer_P; > > =C2=A0=C2=A0 end record; > >=20 > > =C2=A0=C2=A0 procedure Init (r: access Rec); > > end Aux; > > --=20 > > package body Aux is > > =C2=A0=C2=A0 procedure Init (r: access Rec) is > > =C2=A0=C2=A0 begin > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 r.p:=3D r.a'Access; > > =C2=A0=C2=A0 end Init; > > end Aux; > > --=20 > > with Aux; > > procedure Test is > > =C2=A0=C2=A0 r:=C2=A0=C2=A0=C2=A0 aliased Aux.Rec; > > begin > > =C2=A0=C2=A0 Aux.Init (r'Access); > > end Test; > > --=20 > >=20 > > Somewhat surprisingly to me, any call of the form > "Aux.Init (r'Unchecked_Access)" also works, whether "r" is a=20 > library-level object or a local (limited-life) object, even if=20 > "Aux.Init" itself uses "'Access" and not "'Unchecked_Access". Apparently= =20 > the accessibility level provided in the value of Unchecked_Access is=20 > such as to make the check succeed, as for a library-level object. >=20 Yeah, RM section 13.10 says it treats it as if the object were declared at library level for Unchecked_Access > I also found that a call like "Aux.Init (new Aux.Rec)", which applies=20 > "Aux.Init" to a heap-allocated "Rec" object, fails the accessibility=20 > check, so this check is really strict. Of course, the heap object can be= =20 > deallocated at any time, so it may have a short life-time, but that can= =20 > be done (mainly) by Unchecked_Deallocation, so it involves "unchecked"=20 > programming. Hm. >=20 Is that because the heap allocated object is allocated using an anonymous access type instead of a named access type per chance? I know anonymous access types have different accessibility level rules. It might be setting the accessibility level to the point of call maybe?