From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:1754:: with SMTP id l20mr24049240qtk.309.1634460075673; Sun, 17 Oct 2021 01:41:15 -0700 (PDT) X-Received: by 2002:a25:4d83:: with SMTP id a125mr6451701ybb.277.1634460075366; Sun, 17 Oct 2021 01:41:15 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 17 Oct 2021 01:41:15 -0700 (PDT) In-Reply-To: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=94.31.101.123; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 94.31.101.123 References: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com> Subject: Re: Is this legal? From: AdaMagica Injection-Date: Sun, 17 Oct 2021 08:41:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:63026 List-Id: > procedure Main is=20 >=20 > subtype str5 is string(1..5);=20 > type s5_ptr is access all str5;=20 Ptr: s5_ptr; > type T is=20 > record=20 > --current : access str5;=20 > current : s5_ptr; -- "aliased actual has wrong accessibility"=20 > foo : aliased str5;=20 > end record;=20 The accessibility rules are far too complicated and unreadable (I'm not abo= ut trying to grock them), but the component current has a type that has a l= ifetime as long as Main. Your object o may be declared in an inner scope wi= th less lifetime. Thus the assignment must be illegal. begin declare o : T :=3D (Acurrent =3D> null, --Ncurrent =3D> null, foo =3D> "Hello"); begin P (o); --Ptr :=3D o.Ncurrent; -- global point to disappearing object Ptr :=3D o.Acurrent; -- global point to disappearing object end; put_line(Ptr.all); -- prints Hello end Main; But it occurs to me that GNAT CE 2021 has a problem here. (Comment out all = occurrences of Ncurrent.)