https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123306

            Bug ID: 123306
           Summary: Mutably tagged types cause bug box when used as
                    generic arguments
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liam at liampwll dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Given the below sample program, a bug box is generated when a mutably tagged
type is used as an argument for a generic package. Tested on 15.2.1 and current
trunk. The stack trace from trunk also below indicates that Etype is returning
0 but I don't know enough about GNAT internals to debug beyond that:

| 16.0.0 20251225 (experimental) (x86_64-pc-linux-gnu) Assert_Failure failed
precondition from einfo-entities.ads:219|
| Error detected at example.adb:12:4                                       |


#7  0x0000000000bf1327 in einfo.utils.is_private_type (id=0) at
../../gcc/gcc/ada/einfo-utils.adb:371
#8  einfo.utils.root_type (id=12743) at ../../gcc/gcc/ada/einfo-utils.adb:2613


pragma Extensions_Allowed (All_Extensions);

procedure Example is
   generic
      type T is private;
   package Foo is
   end Foo;

   type Mutably_Tagged is tagged null record with Size'Class => 128;
   type Regular_Tagged is tagged null record;

   package My_Foo is new Foo (Mutably_Tagged'Class);  --  Bug box
   --  package My_Foo is new Foo (Mutably_Tagged);  --  Works
   --  package My_Foo is new Foo (Regular_Tagged'Class); --  Errors, as
expected
begin
    null;
end Example;

Reply via email to