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

--- Comment #3 from Andrew Teylu <andrew.teylu at vector dot com> ---
Compiling a package whose body contains a separate nested package body crashes
the compiler when the separate body defines and instantiates a generic package.

Source files are attached as a single gnatchop-able file (`input.txt`).

Command: `gnatchop input.txt && gcc -c pkg.adb`

With GCC 16.0.1 20260315 (experimental):

```
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/avj/opt/gnat-x86_64-linux-16.0.0-20260315/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure
--prefix=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gcc/install
--with-build-time-tools=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/binutils/install/bin
--enable-languages=c,ada,c++ --enable-libstdcxx --enable-libstdcxx-threads
--enable-libada --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch
--enable-lto --disable-multilib --enable-threads=posix --enable-default-pie
--with-gnu-ld --with-gnu-as
--with-mpfr=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpfr/install
--with-gmp=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gmp/install
--with-mpc=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpc/install
--with-isl=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/isl/install
--build=x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.1 20260315 (experimental) (GCC)
```

```
+===========================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.                                       |
+==========================================================================+

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).

pkg.adb
pkg.ads
pkg-sep.adb

compilation abandoned
```

With GCC 15.2.0:

```
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/avj/opt/gnat-x86_64-linux-15.2.0-1/bin/../libexec/gcc/x86_64-pc-linux-gnu/15.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure
--prefix=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gcc/install
--with-build-time-tools=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/binutils/install/bin
--enable-languages=c,ada,c++ --enable-libstdcxx --enable-libstdcxx-threads
--enable-libada --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch
--enable-lto --disable-multilib --enable-threads=posix --enable-default-pie
--with-gnu-ld --with-gnu-as
--with-mpfr=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpfr/install
--with-gmp=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gmp/install
--with-mpc=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpc/install
--with-isl=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/isl/install
--build=x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.0 (GCC)
```

```
+===========================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.                                       |
+==========================================================================+

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).

pkg.adb
pkg.ads
pkg-sep.adb

compilation abandoned
```

Expected behavior: compilation succeeds without error.

Actual behavior: the compiler crashes with an ICE (bug box shown above) on both
GCC 15.2.0 and 16.0.1.

Both compilers are from Alire.

Reply via email to