https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117861
Bug ID: 117861 Summary: pragma Suppress (Overflow_check) is ignored and overflow fails at compilation rather than throwing an exception Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: 00120260a at gmail dot com CC: dkm at gcc dot gnu.org Target Milestone: --- +===========================GNAT BUG DETECTED==============================+ | 14.2.0 (x86_64-pc-linux-gnu) GCC error: | | in gnat_to_gnu, at ada/gcc-interface/trans.cc:6333 | | Error detected at increment_integer.adb:6:29 | | Compiling increment_integer.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. | +==========================================================================+ > procedure Increment_integer (I: in out Integer) is > A: Integer := Integer'Last; > pragma suppress (Overflow_Check, A); > pragma suppress (Range_Check, A); > begin > A := Integer'Succ (A); > end Increment_integer; It's to showcase a need I have a variable that risks causing an overflow (of its subtype or base type) at the end of a loop that fills an array, but only at the last iteration so it doesn't matter, and only in case the array's last index equals the index's base type last possible value. While a table is unlikely to have Positive'Last as an index, it could be indexed with Boolean, so the last iteration of the loop WILL necessarily causes overflow. It should normally trigger a Constraint_Error, that I can catch, but I want to suppress the check instead. But `A := Integer'Succ (A);` is straight up refused.