https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123580
--- Comment #4 from Eryndlia Mavourneen <efmavourneen at axioaction dot org> ---
I now have been able to create a "simple" example that reproduces the bug:
grandparent.ads
---------------
package GrandParent is
type GPT is interface;
end GrandParent;
grandparent-parent.ads
----------------------
generic
package Grandparent.Parent is
type PT is new GPT with private;
Zippo_PT : constant PT;
private
type PT is new GPT with
record
Pos_Pi : Natural := 314159265;
end record;
Zippo_PT : constant PT := (Pos_Pi => 0);
end Grandparent.Parent;
grandparent-parent-child.ads
----------------------------
generic
package Grandparent.Parent.Child is
type CT is new GPT with private;
Zippo_CT : constant CT;
private
type CT is new PT with
record
Small_Pi : Natural := 314;
end record;
-----------------------------------------------------------------------------------------------------------------------
-- The two versions of the constant's completion vary only in that the second
one specifies the package ancestry.
-- The first declaration causes GNAT to complain that it can't find Zippo_PT.
-- The second declaration forces GNAT to look more closely (?), causing the bug
box to be produced.
-----------------------------------------------------------------------------------------------------------------------
-- Zippo_CT : constant CT := (Zippo_PT with Small_Pi => 0);
Zippo_CT : constant CT := (Grandparent.Parent.Zippo_PT with Small_Pi => 0);
end Grandparent.Parent.Child;
main.adb
--------
with Grandparent.Parent.Child;
with Test;
procedure main is
package GP_P is new Grandparent.Parent;
procedure My_Test is new Test (GP_P);
begin
null;
end main;
test.ads
--------
with Grandparent.Parent;
generic
with package InstanParent is new Grandparent.Parent (<>);
procedure Test;
test.adb
--------
with Grandparent.Parent.Child;
procedure Test is
package InstanChild is new InstanParent.Child;
begin
null;
end Test;
----- BUG PRINTOUT ---------------------------------------------------
gprbuild -ws -c -f -u -gnat2022
-PD:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\sandbox.gpr
grandparent-parent-child.ads
Compile
[Ada] grandparent-parent-child.ads
[2026-01-18 08:37:41] process terminated successfully, elapsed time: 02.59s
gprbuild -ws -c -f -u -gnat2022
-PD:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\sandbox.gpr
test.adb
Compile
[Ada] test.adb
+===========================GNAT BUG DETECTED==============================+
| 15.2.0 (x86_64-w64-mingw32) Program_Error sem_ch8.adb:5939 explicit raise|
| Error detected at grandparent-parent-child.ads:16:43 [test.adb:3:4] |
| Compiling
D:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\test.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. |
compilation of test.adb failed
| 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\Sandbox-Constant_of_Split_Type\test.adb
D:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\test.ads
D:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\grandparent.ads
D:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\grandparent-parent.ads
D:\Users\DEVELOPMENT\Software_Development\Sandbox-Constant_of_Split_Type\grandparent-parent-child.ads
compilation abandoned
gprbuild: *** compilation phase failed
[2026-01-18 08:37:54] process exited with status 4, elapsed time: 02.29s