https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124607

            Bug ID: 124607
           Summary: Generic instantiation in separate package body causes
                    ICE
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrew.teylu at vector dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Compiling a package whose body contains a separate nested package body crashes
the compiler when the separate body defines and instantiates a generic package.

`pkg.ads`:

```ada
package Pkg is
   pragma Elaborate_Body;
   package Sep is
      function F return Boolean;
   end Sep;
end Pkg;
```

`pkg.adb`:

```ada
package body Pkg is
   package body Sep is separate;
end Pkg;
```

`pkg-sep.adb`:

```ada
separate (Pkg)
package body Sep is
   function F return Boolean is
   begin
      return True;
   end F;
   generic
   package G is
   end G;
   package I is new G;
end Sep;
```

Compiled with `gcc -c pkg.adb`.

With GCC 16.0.1 20260315 (experimental):

```
+===========================GNAT BUG DETECTED==============================+
| 16.0.1 20260315 (experimental) (x86_64-pc-linux-gnu) Assert_Failure failed
precondition from sinfo-nodes.ads:3756|
| Error detected at pkg-sep.adb:10:4                                       |
| Compiling pkg.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.                                       |
+==========================================================================+
```

With GCC 15.2.0:

```
+===========================GNAT BUG DETECTED==============================+
| 15.2.0 (x86_64-pc-linux-gnu) Storage_Error stack overflow or erroneous memory
access|
| Error detected at pkg-sep.adb:10:4                                       |
| Compiling pkg.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.                                       |
+==========================================================================+
```

Both compilers are from Alire.

Reply via email to