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

            Bug ID: 123371
           Summary: Bug box or infinite loop when using container
                    aggregate key expression under some circumstances
           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: ---

When a container aggregate contains a key expression and the type of the
iterable is either a qualified expression or returned from a function,
Exp_Util.Insert_Actions will get stuck in a loop calling Parent on an empty
node ID. With assertions enabled it will crash instead until making that call.
Tested on trunk and 15.2.1. Reproducer below:

pragma Ada_2022;

with Ada.Containers.Ordered_Maps;

procedure Example is
   package Maps is new Ada.Containers.Ordered_Maps (Integer, Integer);

   function F return Maps.Map is ([]);

   A : Maps.Map := [for I of Maps.Map'[] => 1]; --  Works
   B : Maps.Map := [for I of A => 1]; --  Works
   C : Maps.Map := [for I of B use 1 => 1]; --  Works
   D : Maps.Map := [for I of F => 1]; --  Works

   X : Maps.Map := [for I of Maps.Map'[] use 1 => 1]; --  Infinite loop
   Y : Maps.Map := [for I of F use 1 => 1]; --  Infinite loop
begin
   null;
end Example;

Reply via email to