[Bug ada/118712] [13/14/15 regression] segfault on missing body for primitive operator of derived real type

2025-01-31 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118712

--- Comment #2 from Andrew Teylu  ---
As a note, the code is minimised into "being invalid".

Here is a version that compiles without errors with 12.1 but still gives an ICE
on 14.2.1:

`stub.ads`:

```
package Stub is
   type GenT is delta 1.0 range 1.0 .. 10.0;
   function "-" (X : GenT; Y : GenT) return GenT;
   type DerT is new GenT;
end Stub;
```

`stub.adb`:

```
package body Stub is
   function "-" (X : GenT; Y : GenT) return GenT is
   begin
  return GenT (X) - GenT (Y);
   end "-";
   procedure Proc is
  Var : DerT;
  Initialised : Boolean := False;
   begin
  loop
 if (Initialised) then
Var := 1.0 - Var;
 end if;
 Initialised := True;
 Var := 2.0;
  end loop;
   end Proc;
end Stub;
```

Output with 12.1:

```
stub.adb:12:26: warning: "Var" may be referenced before it has a value [enabled
by default]
```

With 14.2.1:

```
+===GNAT BUG DETECTED==+
| 14.2.1 20241007 [revision 4af44f2cf7d281f3e4f3957efce10e8b2ccb2ad3]
(x86_64-suse-linux) |
| Storage_Error stack overflow or erroneous memory access  |
| Error detected at stub.adb:6:4   |
| Compiling stub.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).

stub.adb
stub.ads

compilation abandoned
```

[Bug ada/118712] New: "Storage_Error stack overflow or erroneous memory access" with ranged types

2025-01-31 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118712

Bug ID: 118712
   Summary: "Storage_Error stack overflow or erroneous memory
access" with ranged types
   Product: gcc
   Version: 14.2.1
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: ---

For the following Ada package:

`stub.ads`:

```
package Stub is
   type GenT is delta 1.0 range 1.0 .. 10.0;
   function "-" (X : GenT; Y : GenT) return GenT;
   type DerT is new GenT;
end Stub;
```

`stub.adb`:

```
package body Stub is
   procedure Proc is
  Var : DerT;
   begin
  Var := 1.0 - Var;
   end Proc;
end Stub;
```

Compiling with gcc 14.2.1 gives:

```
+===GNAT BUG DETECTED==+
| 14.2.1 20241007 [revision 4af44f2cf7d281f3e4f3957efce10e8b2ccb2ad3]
(x86_64-suse-linux) |
| Storage_Error stack overflow or erroneous memory access  |
| Error detected at stub.adb:2:4   |
| Compiling stub.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).

stub.adb
stub.ads

compilation abandoned
```

The same bug reproduces with 14.2.0 from Alire.

I tested with a build of 12.1.0, and the bug does not reproduce there:

```
gcc --version
gcc (GCC) 12.1.0
Copyright (C) 2022 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.
```

```
stub.adb:1:14: error: missing body for "-" declared at stub.ads:3
stub.adb:5:20: warning: "Var" may be referenced before it has a value [enabled
by default
```

[Bug debug/121157] -gcodeview does not work with Ada

2025-07-19 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121157

--- Comment #10 from Andrew Teylu  ---
Btw, it isn't that it _never_ works:

```
package LOCAL_IO is
   function GET_NEXT return Integer;
end LOCAL_IO;
package body LOCAL_IO is
   type TEXT_TYPE (LENGTH : Positive := 1) is record
  null;
   end record;
   DESCRIPTOR : TEXT_TYPE;
   function GET_NEXT return Integer is
   begin
  return 1;
   end GET_NEXT;
end LOCAL_IO;
with LOCAL_IO;
procedure Main is
   Value : Integer;
begin
   null;
   Value := LOCAL_IO.GET_NEXT;
end Main;
```

Steps:

```
gnatchop.exe -w input.txt

gcc.exe -g -gcodeview -c *.adb

gnatbind.exe main.ali

gcc.exe -g -c b~main.adb

gcc.exe -g -gcodeview -Wl,--pdb=main.pdb -g -O0 b~main.o main.o local_io.o -o
main
-L/home/avj/gnat-x86_64-windows64-15.1.0-2/lib/gcc/x86_64-w64-mingw32/15.1.0/adalib/
-lgnat -Wl,--subsystem,console
```

This does complete without error and generate `main.pdb`.

It does crash if you use `-gcodeview` on the binder file, so I've omitted that.

[Bug debug/121157] -gcodeview does not work with Ada

2025-07-20 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121157

--- Comment #11 from Andrew Teylu  ---
Ah, no, I think Eric is correct in that it doesn't work at all (even if gcc
doesn't fail).

I used https://github.com/Microsoft/microsoft-pdb/blob/master/cvdump/cvdump.exe
to look at the pdb file generated when compiling/linking my example, and the
`*** LINES` section looked like this:

```
** Module: "D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/b~main.o"

Mod::GetEnumLines failed

** Module: "D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/main.o"

** Module: "D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/local_io.o"
```

Notice: for the two files we compile with `-gcodeview` they _do not_ have
`Mod::GetEnumLines failed` (which, I think, means there is PDB info for those
objects, but it is empty).

I then wrote a matching C version (including a binder main that I did not
compile with `-gcodeview` to match what I did for Ada), and the `*** LINES`
section looked like this:

```
** Module: "D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/c/b_main.o"

Mod::GetEnumLines failed

** Module: "D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/c/main.o"

  D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/c/main.c (MD5:
7935177CE228764361F5487B3BDA29AC), 0001:05E0-05F7, line/addr pairs = 3

  4 05E0  5 05E8  6 05F0

** Module: "D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/c/local_io.o"

  D:/DEV/msys64/home/ateylu/alire/tom_121157/v3/c/local_io.c (MD5:
5997CD3181362A6DA3EF9CCAA4E0B36D), 0001:0600-060B, line/addr pairs = 3

  4 0600  5 0604  6 0609
```

That is, there is the debug information for the object files (and, as we'd
like, not for the binder main).

[Bug debug/121157] internal error on Ada's unconstrained array types with -gcodeview

2025-07-18 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121157

--- Comment #7 from Andrew Teylu  ---
Yeah, so my reduced file no longer crashes if you use `-fgnat-encodings=all`.

Re-reducing Tom's original files while `-fgnat-encodings=all` still gives a
crash:

```
package LOCAL_IO is
   function GET_NEXT return Integer;
end LOCAL_IO;
package body LOCAL_IO is
   type TEXT_TYPE (LENGTH : Positive := 2) is record
  null;
   end record;
   DESCRIPTORS : array (1 .. 0) of TEXT_TYPE;
   function GET_NEXT return Integer is
   begin
  return 1;
   end GET_NEXT;
end LOCAL_IO;
```

Steps:

```
gnatchop -w input.txt
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -c local_io.adb # no error
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -gcodeview -fgnat-encodings=all
-c local_io.adb
```

Where the last gives:

```
+===GNAT BUG DETECTED==+
| 15.1.0 (x86_64-w64-mingw32) in AT_unsigned, at dwarf2out.cc:4572 |
| Error detected around local_io.adb:10:1  |
| Compiling local_io.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).

local_io.adb
local_io.ads


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:422
```

[Bug ada/121162] New: GNAT hang with `-gcodeview -fgnat-encodings=all` (but not just with `-gcodeview`)

2025-07-18 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121162

Bug ID: 121162
   Summary: GNAT hang with `-gcodeview -fgnat-encodings=all` (but
not just with `-gcodeview`)
   Product: gcc
   Version: 15.1.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: ---

For the following file:

```
package MINIMAL_HANG is
   type RANGE_TYPE is range 1 .. 11;
   function SOME_FUNCTION (str : String) return String;
end MINIMAL_HANG;
package body MINIMAL_HANG is
   type NULL_RECORD is record
  null;
   end record;
   ARRAY_VAR : array (RANGE_TYPE) of NULL_RECORD;
   function SOME_FUNCTION (str : String) return String is
   begin
  return str;
   end SOME_FUNCTION;
end MINIMAL_HANG;
```

and with the following steps:

```
gnatchop -w input.txt
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -gcodeview -c minimal_hang.adb #
doesn't hang
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -gcodeview -fgnat-encodings=all
-c minimal_hang.adb # hangs
```

Then `gcc` doesn't appear to terminate.

GCC version:

```
Using built-in specs.
COLLECT_GCC=Z:\home\avj\gnat-x86_64-windows64-15.1.0-2\bin\gcc.exe
COLLECT_LTO_WRAPPER=Z:/home/avj/gnat-x86_64-windows64-15.1.0-2/bin/../libexec/gcc/x86_64-w64-
mingw32/15.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../src/configure
--prefix=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gcc/inst
all
--with-build-time-tools=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/binutils/install/bin
--
enable-languages=c,ada,c++ --enable-libstdcxx --enable-libstdcxx-threads
--enable-libada --di
sable-nls --without-libiconv-prefix --disable-libstdcxx-pch --enable-lto
--disable-multilib -
-enable-threads=win32
--with-native-system-header-dir=/aaa/GNAT-FSF-builds/sbx/x86_64-windows
64/gcc/install/include --with-gnu-ld --with-gnu-as
--with-mpfr=/aaa/GNAT-FSF-builds/sbx/x86_6
4-windows64/mpfr/install
--with-gmp=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gmp/install --w
ith-mpc=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/mpc/install
--with-isl=/aaa/GNAT-FSF-builds
/sbx/x86_64-windows64/isl/install --build=x86_64-w64-mingw32
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 15.1.0 (GCC)
```

Compiler taken from here:
https://github.com/alire-project/GNAT-FSF-builds/releases/tag/gnat-15.1.0-2

[Bug ada/121163] New: GNAT hang with `-g -gcodeview` (but not with just `-g`)

2025-07-18 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121163

Bug ID: 121163
   Summary: GNAT hang with `-g -gcodeview` (but not with just
`-g`)
   Product: gcc
   Version: 15.1.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: ---

For the following file:

```
package LOCAL_IO is
   function GET_NEXT return Integer;
end LOCAL_IO;
package body LOCAL_IO is
   type TEXT_TYPE is record
  null;
   end record;
   DESCRIPTORS : array (1 .. 2) of TEXT_TYPE;
   function GET_NEXT return Integer is
   begin
  return 1;
   end GET_NEXT;
end LOCAL_IO;
```

and the following steps:

```
gnatchop -w input.txt
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g  -c local_io.adb # doesn't hang
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -gcodeview -c local_io.adb #
hangs
```

Then `gcc` doesn't appear to terminate.

GCC version:

```
Using built-in specs.
COLLECT_GCC=Z:\home\avj\gnat-x86_64-windows64-15.1.0-2\bin\gcc.exe
COLLECT_LTO_WRAPPER=Z:/home/avj/gnat-x86_64-windows64-15.1.0-2/bin/../libexec/gcc/x86_64-w64-mingw32/15.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../src/configure
--prefix=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gcc/install
--with-build-time-tools=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/binutils/install/bin
--enab
le-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=win32
--with-native-system-header-dir=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gcc/install/include
--with-gnu-ld --with-gnu-as
--with-mpfr=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/
mpfr/install --with-gmp=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gmp/install
--with-mpc=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/mpc/install
--with-isl=/aaa/GNAT-FSF-builds/sbx/x86_64-wind
ows64/isl/install --build=x86_64-w64-mingw32
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 15.1.0 (GCC)
```

Compiler taken from here:
https://github.com/alire-project/GNAT-FSF-builds/releases/tag/gnat-15.1.0-2

[Bug ada/121157] GNAT internal error when using -gcodeview

2025-07-18 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121157

--- Comment #4 from Andrew Teylu  ---
As a note, my version of GCC comes from
https://github.com/alire-project/GNAT-FSF-builds/releases/tag/gnat-15.1.0-2

```
Using built-in specs.
COLLECT_GCC=Z:\home\avj\gnat-x86_64-windows64-15.1.0-2\bin\gcc.exe
COLLECT_LTO_WRAPPER=Z:/home/avj/gnat-x86_64-windows64-15.1.0-2/bin/../libexec/gcc/x86_64-w64-mingw32/15.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../src/configure
--prefix=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gcc/install
--with-build-time-tools=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/binutils/install/bin
--enab
le-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=win32
--with-native-system-header-dir=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gcc/install/include
--with-gnu-ld --with-gnu-as
--with-mpfr=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/
mpfr/install --with-gmp=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/gmp/install
--with-mpc=/aaa/GNAT-FSF-builds/sbx/x86_64-windows64/mpc/install
--with-isl=/aaa/GNAT-FSF-builds/sbx/x86_64-wind
ows64/isl/install --build=x86_64-w64-mingw32
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 15.1.0 (GCC)
```

[Bug ada/121157] GNAT internal error when using -gcodeview

2025-07-18 Thread andrew.teylu at vector dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121157

Andrew Teylu  changed:

   What|Removed |Added

 CC||andrew.teylu at vector dot com

--- Comment #3 from Andrew Teylu  ---
I reduced Tom's example to:

```
package LOCAL_IO is
   function GET_NEXT (str : String) return String;
end LOCAL_IO;
package body LOCAL_IO is
   function GET_NEXT (str : String) return String is
   begin
  return str;
   end GET_NEXT;
end LOCAL_IO;
```

To check:

```
gnatchop -w input.txt
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -c local_io.adb # no error
gnat-x86_64-windows64-15.1.0-2/bin/gcc.exe -g -gcodeview -c local_io.adb
```

Where the last gives:

```
+===GNAT BUG DETECTED==+
| 15.1.0 (x86_64-w64-mingw32) in AT_unsigned, at dwarf2out.cc:4572 |
| Error detected around local_io.adb:6:1   |
| Compiling local_io.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).

local_io.adb
local_io.ads


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:422
```

What's interesting is `local_io.adb:6:1` is the start of the last line in the
file (the error is always at the last line, irrespective of what's in the
file).