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

            Bug ID: 124426
           Summary: Sem_Util.Has_Null_Extension does not account for
                    variant part, leading to assertion failure
           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: ---

Created attachment 63862
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63862&action=edit
fix

There's a reproducer for this below and a fix attached, although I'm not
entirely sure if the fix is correct.

Specifically, the current code with assertions disabled considers a type to
have a null extension if it has a variant part and no components outside of the
variant, but that seems incorrect given that this is called from
Sem_Util.Is_Fully_Initialized_Type. My patch changes this so such a type is not
considered to have a null extension. That being said, I have not observed
initialisation being incorrect with either option so some further analysis is
required.


pragma Ada_2022;

with Ada.Finalization;

procedure Example is
   generic
   package Pack is
      type T (D : Boolean := True) is new Ada.Finalization.Limited_Controlled
      with record
         case D is
            when others =>
               null;
         end case;
      end record;

      overriding
      procedure Finalize (Object : in out T);
   end Pack;

   package body Pack is
      overriding
      procedure Finalize (Object : in out T) is
      begin
         null;
      end Finalize;
   end Pack;
begin
   null;
end Example;

Reply via email to