From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: Is this legal?
Date: Sun, 17 Oct 2021 01:41:15 -0700 (PDT) [thread overview]
Message-ID: <54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com> (raw)
In-Reply-To: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
> procedure Main is
>
> subtype str5 is string(1..5);
> type s5_ptr is access all str5;
Ptr: s5_ptr;
> type T is
> record
> --current : access str5;
> current : s5_ptr; -- "aliased actual has wrong accessibility"
> foo : aliased str5;
> end record;
The accessibility rules are far too complicated and unreadable (I'm not about trying to grock them), but the component current has a type that has a lifetime as long as Main. Your object o may be declared in an inner scope with less lifetime. Thus the assignment must be illegal.
begin
declare
o : T := (Acurrent => null, --Ncurrent => null,
foo => "Hello");
begin
P (o);
--Ptr := o.Ncurrent; -- global point to disappearing object
Ptr := 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.)
next prev parent reply other threads:[~2021-10-17 8:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-16 19:00 Is this legal? Simon Belmont
2021-10-17 8:35 ` Gautier write-only address
2021-10-17 8:41 ` AdaMagica [this message]
2021-10-17 18:31 ` Simon Belmont
2021-10-18 10:50 ` AdaMagica
2021-10-19 3:50 ` Randy Brukardt
-- strict thread matches above, loose matches on Subject: below --
1991-11-09 18:02 Is this legal ? Bud Bach
1991-11-09 3:20 Robert I. Eachus
1991-11-08 20:58 Boris Pelakh
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox