From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a0c:f68f:: with SMTP id p15mr28159375qvn.55.1618939103359; Tue, 20 Apr 2021 10:18:23 -0700 (PDT) X-Received: by 2002:a25:75d6:: with SMTP id q205mr25333235ybc.339.1618939103198; Tue, 20 Apr 2021 10:18:23 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!weretis.net!feeder8.news.weretis.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: Tue, 20 Apr 2021 10:18:23 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=35.245.252.196; posting-account=XfA3zgkAAABoz6fRf3Tehtnqqr7Ycml- NNTP-Posting-Host: 35.245.252.196 References: <962020bb-97fc-42c3-8255-8f9b2bcbe204n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <13f272e5-14a3-45cb-abf2-3d9f5a98f715n@googlegroups.com> Subject: Re: 'address on a subprogram parameter From: Vincent Marciante Injection-Date: Tue, 20 Apr 2021 17:18:23 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:61863 List-Id: On Tuesday, April 20, 2021 at 12:35:07 PM UTC-4, J-P. Rosen wrote: > Le 20/04/2021 =C3=A0 17:10, Vincent Marciante a =C3=A9crit :=20 > > I think that I used to know this but currently am not sure:=20 > >=20 > > Assuming the a value is passed by reference, is 'Address of a parameter= =20 > > always the address of the object that is passed as in:=20 > >=20 > > ...=20 > >=20 > > type Big_Record is ...=20 > >=20 > > Object : Big_Record;=20 > >=20 > > procedure Proc (Param : in out Big_Record) is=20 > > begin=20 > > if Param'Address /=3D Object'Address then=20 > > raise Constraint_Error;=20 > > end if;=20 > > end;=20 > >=20 > > begin=20 > > Proc(Object);=20 > > ...=20 > > > As usual, the real question is "why do you need that?"=20 >=20 > If you want to check whether a parameter IS a certain variable, use=20 > Param'Has_Same_Storage(Object). If you want to check whether variables=20 > have a part in common, use Param'Overlaps_Storage (Object).=20 > See 13.3 (73.1/3 .. 73.10/3)=20 >=20 >=20 > --=20 > J-P. Rosen=20 > Adalog=20 > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX=20 > Tel: +33 1 45 29 21 52=20 > https://www.adalog.fr I actually do not want to test that: I just wrote that as an attempt to make explicit want I was asking and what I did not expect (exception). I am really working with old code where I am moving some logic out=20 from within a package body that contains the "address'd" variable to an unassociated package that defines the "Big_Record" type and I wanted to be sure that passing it as a parameter would (always) have the same behavior with the variable being passed as a parameter.