#278831 Illegal program not detected, access to invisible type RM 8.2(9)

Package:
gnat-12
Source:
gcc-12
Description:
GNU Ada compiler
Submitter:
Date:
2025-11-06 17:39:13 UTC
Severity:
normal
Tags:
#278831#5
Date:
2004-10-29 16:31:40 UTC
From:
To:
package Test_128 is

   package inner is
   private
      type T1;
      type T2 is null record;
   end inner;

   type T1_ptr is access inner.T1; -- line  9 ERROR: gnat mistakenly accepts
   type T2_ptr is access inner.T2; -- line 10 ERROR: gnat correctly rejects
end Test_128;

The output of the compiler is:

test_128.ads:10:31: "T2" is not a visible entity of "inner"
gnatmake: "test_128.ads" compilation error

As can be seen, the error at line 9 is not diagnosed.

#278831#18
Date:
2009-01-02 19:33:00 UTC
From:
To:
found 269948 4.3.2-2
found 276224 4.3.2-2
found 278687 4.3.2-2
found 278831 4.3.2-2
found 279893 4.3.2-2
found 280939 4.3.2-2
found 283835 4.3.2-2
thanks

#278831#33
Date:
2011-08-31 13:09:43 UTC
From:
To:
reassign 278831 gnat-4.6
found 278831 4.6.1-5
thanks

I suggest providing a body to avoid any other illegality.

package Test_128 is
   package inner is
   private
      type T1;
   end inner;
   type T1_ptr is access inner.T1; -- line  9 ERROR: gnat mistakenly accepts
end Test_128;
package body test_128 is
   package body inner is
      type T1 is new Integer;
   end inner;
end Test_128;