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

            Bug ID: 121316
           Summary: Representation clauses silently cause iterator filters
                    to be ignored
           Product: gcc
           Version: 16.0
            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: ---

The following code enters the loop in all cases despite the iterator filter.
This only occurs when the representation clause is present. This occurs on all
versions from 13.2 through to current trunk. 13.1 instead crashes. All versions
crash if `Use_Foo (F)'Image` is replaced with `Use_Foo'Image`.

procedure Example is
   type Foo is (A, B, C);
   for Foo use (A => 1, B => 2, C => 3);
   type Use_Foo_Type is array (Foo) of Boolean;
   Use_Foo : Use_Foo_Type := (A => True, B => False, C => True);
begin
   for F in Foo when Use_Foo (F) loop
      Put_Line (F'Image);
      Put_Line (Use_Foo (F)'Image);
   end loop;
end Example;

Reply via email to