Simon Belmont
2021-10-16 19:00:18 UTC
I'm trying to learn the 2012 changes to accessibility rules, e.g. aliased parameters, additional dynamics checks, and some eliminated unnecessary typecasts. But I am also aware of the....fluid nature of GNATs correctness of implementing them, and the following situation seems dubious. In particular, when 'current' is an anonymous access type, it compiles without issue, but not when it's a named access type (or when explicitly converted to one). Does anyone know off hand which is the correct behavior?
Thanks
-sb
procedure Main is
subtype str5 is string(1..5);
type s5_ptr is access all str5;
type T is
record
current : access str5;
--current : s5_ptr; -- "aliased actual has wrong accessibility"
foo : aliased str5;
end record;
function F (y : aliased in out str5) return access str5 is
begin
return y'Access;
end F;
procedure P (x : in out T) is
begin
x.current := F(x.foo);
end P;
o : T := (current => null, foo => "Hello");
begin
P(o);
end Main;
Thanks
-sb
procedure Main is
subtype str5 is string(1..5);
type s5_ptr is access all str5;
type T is
record
current : access str5;
--current : s5_ptr; -- "aliased actual has wrong accessibility"
foo : aliased str5;
end record;
function F (y : aliased in out str5) return access str5 is
begin
return y'Access;
end F;
procedure P (x : in out T) is
begin
x.current := F(x.foo);
end P;
o : T := (current => null, foo => "Hello");
begin
P(o);
end Main;