https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109798
Bug ID: 109798
Summary: Gnat Bug Detected
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: aj at ianozi dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Steps to reproduce:
1) Create test program called "testing.adb" with the following contents:
```
pragma Ada_2022;
procedure Testing is
type Test_Enum is (apple, orange, banana);
type Test_Type is record
The_Type : Test_Enum;
The_Value : Integer;
end record;
type Test_Array is array (Positive range <>) of Test_Type;
My_Array : Test_Array (1 .. 6) := ( (apple, 5), (orange, 10), (banana, 1),
(orange, 15), (orange, 12), (apple, 5) );
begin
for I in My_Array'Range
when My_Array (I).The_Type /= orange
loop
null;
end loop;
end Testing;
```
2) Compile with gcc 12.0 or greater (I tested it with both gcc 12.2.0 or MacOS
and Debian)
The following output occurs and it fails:
```
ⓘ Building testing/testing.gpr...
Compile
[Ada] testing.adb
+===========================GNAT BUG DETECTED==============================+
| 12.1.0 (x86_64-apple-darwin19.6.0) GCC error: |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.cc:472 |
| Error detected at testing.adb:13:21 |
| Compiling /Users/ianozi/projects/testing/testing/src/testing.adb |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ . |
| Use a subject line meaningful to you and us to track the bug. |
| Include the entire contents of this bug box in the report. |
| Include the exact command that you entered. |
| Also include sources listed below. |
+==========================================================================+
Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).
/Users/ianozi/projects/testing/testing/src/testing.adb
testing.adb:10:04: warning: "My_Array" is not modified, could be declared
constant [-gnatwk]
testing.adb:10:38: warning: array aggregate using () is an obsolescent syntax,
use [] instead [-gnatwj]
testing.adb:10:39: (style) space not allowed
compilation abandoned
compilation of testing.adb failed
gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P",
"/Users/ianozi/projects/testing/testing/testing.gpr"] exited with code 4
error: Compilation failed.
```
I get the same thing on debian, except the gnat bug detected says
```
| 12.2.0 (x86_64-pc-linux-gnu) GCC error: |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.cc:472 |
```
Instead of the apple-darwin stuff.
The same thing happens if I remove the "pragma Ada_2022;" from the beginning of
the program and just compile it with the gnat2022 switch.
Is this happening for anyone else?
I apologize if I'm filing this bug wrong, or if it's a duplicate, it's the
first time I'm doing this.
Kind regards,
AJ.