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

--- Comment #2 from Andrew Teylu <andrew.teylu at vector dot com> ---
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
```

Reply via email to