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

            Bug ID: 127880
           Summary: GNAT BUG DETECTED instantiating generic
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krischik at users dot sourceforge.net
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 65828
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65828&action=edit
Files requested by the bug box.

## Exact version of GCC

```
alr exec -P1 -- gcc --version
gcc (GNAT-FSF-builds) 16.1.0
Copyright (C) 2026 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.
```

## System type

```
alr exec -P1 -- gcc -dumpmachine
x86_64-apple-darwin24.6.0
```

```
uname -a
Darwin iMac.local 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:11:49 PDT
2026; root:xnu-12377.161.14~5/RELEASE_X86_64 x86_64
```

```
sw_vers
ProductName:            macOS
ProductVersion:         26.6.2
BuildVersion:           25G83
```

The same crash also occurs on Windows.

## Options when GCC was configured/built

The compiler is the one delivered by Alire (GNAT-FSF-builds):

```
alr exec -P1 -- gcc -v
Target: x86_64-apple-darwin24.6.0
Configured with: ../src/configure
--prefix=/Users/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-darwin/gcc/install
--enable-languages=c,ada,c++ --enable-libstdcxx --enable-libstdcxx-threads
--enable-libada --with-pkgversion=GNAT-FSF-builds --disable-nls
--without-libiconv-prefix --disable-libstdcxx-pch --enable-lto
--disable-multilib --disable-libcilkrts
--with-build-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
--with-specs='%{!-sysroot=*:--sysroot=%:if-exists-else(/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)}'
--with-mpfr=/Users/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-darwin/mpfr/install
--with-gmp=/Users/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-darwin/gmp/install
--with-mpc=/Users/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-darwin/mpc/install
--build=x86_64-apple-darwin24.6.0
Thread model: posix
```

## Exact command line that triggers the bug

```
alr build --validation -- -v
```

which invokes:

```
gcc -c -x ada -gnatA -Og -ffunction-sections -fdata-sections -g -gnato -gnatwa
-gnatw.X -gnatVa -gnata -gnaty3 -gnatya -gnatyA -gnatyB -gnatyb -gnatyc
-gnaty-d -gnatye -gnatyf -gnatyh -gnatyi -gnatyI -gnatyk -gnatyl -gnatym
-gnatyn -gnatyO -gnatyp -gnatyr -gnatyS -gnatyt -gnatyu -gnatyx -gnat2022
-gnatW8 -gnat2022 -gnatef -gnatW8 -gnatwn -gnatX -gnaty-I -gnatyM200
-gnatec=/private/tmp/GPR.89815/GNAT-TEMP-000003.TMP
-gnatem=/private/tmp/GPR.89815/GNAT-TEMP-000051.TMP
/Users/Shared/Work/Projects/AdaCL/develop/adacl_desktop/test/src/adacl_desktop_test-queue.adb
```

## Source files

A collection of source files is attached. The crash only appears when the
generic is instantiated inside the unit tests, so a modest number of files is
required to reproduce it. A minimal set would be ideal, but the instantiation
context makes that difficult.

## Expected behaviour

The unit tests should compile and an executable should be produced. The library
itself builds without problem; the failure is confined to the test code that
instantiates the generic.

## Actual behaviour

Compilation aborts with a GNAT bug box:

```
+===========================GNAT BUG DETECTED==============================+
| 16.1.0 (x86_64-apple-darwin24.6.0) GCC error:                            |
| x from adacl_desktop_test__queue__string_queue__protect__sychronized_h   |
|    older__delegate__deleter referenced in
adacl_desktop_test__queue__string_queue__tasks__thread_holder__delegate__deleter|
| No source file position information available                            |
| Compiling
/Users/Shared/Work/Projects/AdaCL/develop/adacl_desktop/test/src/adacl_desktop_test-queue.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.                                       |
+==========================================================================+
```

Crashes that only surface when a generic is instantiated are particularly
awkward: the problem is not visible while developing the generic itself and
only appears late, once client code (here the unit tests) tries to use it.

Reply via email to