https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114708
Bug ID: 114708
Summary: Creating access to an incomplete formal in a generic
package sometimes causes GNAT to crash
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: jhb.chat at gmail dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Created attachment 57939
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57939&action=edit
incomplete formal example
When making a generic package that takes an incomplete formal as a parameter
and then creating an access type to that formal type inside the generic, GNAT
will crash if an actual incomplete type is supplied in the generic
instantiation.
This happens on gnat 13.0, on mwys2, Windows 10 Home, fully patched
GNATMAKE 13.2.0
Copyright (C) 1995-2023, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Checked Godbolt and this happens on trunk there and the ICE appeared to start
with GNAT 12.1 as GNAT 11.4 did not trigger the crash (on Godbolt).
Example:
procedure Main is
generic
type Element_Type(<>);
package Test_Incomplete_Formal is
type Element_Access is access Element_Type;
end Test_Incomplete_Formal;
type Node;
package P is new Test_Incomplete_Formal(Node);
type Node is limited null record;
begin
null;
end Main;
Output:
$ gnatmake.exe main.adb
gcc -c main.adb
+===========================GNAT BUG DETECTED==============================+
| 13.2.0 (x86_64-w64-mingw32) Program_Error EXCEPTION_ACCESS_VIOLATION |
| Error detected at main.adb:6:7 [main.adb:11:4] |
| Compiling main.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).
main.adb
compilation abandoned
gnatmake: "main.adb" compilation error