comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Belmont <sbelmont700@gmail.com>
Subject: Is this legal?
Date: Sat, 16 Oct 2021 12:00:18 -0700 (PDT)	[thread overview]
Message-ID: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com> (raw)

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;

             reply	other threads:[~2021-10-16 19:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16 19:00 Simon Belmont [this message]
2021-10-17  8:35 ` Is this legal? Gautier write-only address
2021-10-17  8:41 ` AdaMagica
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