https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123580
Bug ID: 123580
Summary: Constant of Type with Split Inheritance in Generic
Package's Type Definition causes GNAT Failure with Bug
Box
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: efmavourneen at axioaction dot org
CC: dkm at gcc dot gnu.org
Target Milestone: ---
The use of an extension aggregate to declare a constant of a private type with
a split declaration within a child package fails upon instantiation, producing
a Bug Box.
GNAT compiles all 3 packages (represented below) seemingly normally, and
accepts EmptyCT's dclaration. Upon instantiation it apparently loses track of
the definition of EmptyPt. Sometimes, depending on other things, it just exits
with status 4. Other times is complains that it cannot find PT. When "forced"
to see PT via GP.P.PT in the extension aggregate, it generates a Bug Box and
exits.
The workaround is to replace the constant with a normal function call
containing the extension aggregate. An expression function cannot be used,
because of the split declaration.
I have tried to create a minimal reproduction of the issue but so far have not
been able to. If and when I can I will post it.
-----
GP = Grandparent Package. GPT = interface type declared in GP
P = Parent Package. PT = concrete derivation of GPT
CT = Child Package. CT = concrete derivation of GPT and PT
package GP is
type GPT is interface;
end GP;
package GP.P is
type PT is new GPT with private;
EmptyPT : constant PT;
private
type PT is new GPT with record ... end record;
EmptyPT : constant PT := ...;
end GP.P;
CT's declaration is split:
package GP.P.C is
type CT is new GPT with private;
EmptyCT : constant CT;
private
type CT is new PT with
record
I : Natural;
J : Natural;
end record;
EmptyCT : constant CT := (EmptyPT with I => 0, J => 0);
end GP.P.C;
-----
Bug Box:
gprbuild -d -PD:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test.gpr -s
-j9 -O0
Compile
[Ada] test_csvs.adb
[Ada] csvs-strings-named_enum.adb
+===========================GNAT BUG DETECTED==============================+
| 15.2.0 (x86_64-w64-mingw32) Program_Error sem_ch8.adb:5939 explicit raise|
| Error detected at csvs-strings-named_enum.ads:342:60
[harness-ne_tests.adb:8:4]|
| Compiling
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\test_csvs.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).
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\test_csvs.adb
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\csvs_instantiations.ads
D:\Users\DEVELOPMENT\Software_Development\CSV\src\csvs.ads
D:\Users\DEVELOPMENT\Software_Development\CSV\src\csvs-strings.ads
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\harness.ads
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\harness_types.ads
D:\Users\DEVELOPMENT\Software_Development\CSV\src\csvs-strings.adb
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\harness.adb
D:\Users\DEVELOPMENT\Software_Development\CSV\src\csvs-strings-named_enum.ads
D:\Users\DEVELOPMENT\Software_Development\CSV\test\my_test\harness-ne_tests.adb
compilation abandoned
compilation of test_csvs.adb failed
gprbuild: *** compilation phase failed
[2026-01-07 18:15:42] process exited with status 4, 100% (5/5), elapsed time:
04.54s