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 ```