https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117328
Bug ID: 117328
Summary: Iterated component association fails for array indexed
by Stream_Element_Offset
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: simon at pushface dot org
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Created attachment 59469
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59469&action=edit
Reproducer
This code (which originally used Stream_Element_Array)
pragma Ada_2022;
with Ada.Streams;
with Interfaces;
procedure Gast is
use Ada.Streams;
type Bytes is array (Positive range <>) of Interfaces.Unsigned_8;
X : Bytes := [16#ff#, 16#00#, 16#10#, 16#01#];
type Integers is array (Stream_Element_Offset range <>) of Integer;
-- type Integers is array (Integer range <>) of Integer;
Z : Integers := [for Byte of X => Integer (Byte)];
begin
null;
end Gast;
fails with
$ gnatmake gast.adb
gcc -c gast.adb
gast.adb:10:20: error: value not in range of type "Standard.Integer"
gast.adb:10:20: error: static expression fails Constraint_Check
but if the current declaration of type Integers is replaced by the
commented-out one below it, compilation succeeds.