]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix wrong code for indexed component with very large index type
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 24 Nov 2025 09:36:35 +0000 (10:36 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 24 Nov 2025 09:42:45 +0000 (10:42 +0100)
commit04794bba3a6b1ec68947725d973f8fb3f7ea5364
treee91ed298d5c181e7bf69d1f7eb64fd8a3a4af18e
parent8dc9819ed7758b903b825ee48405b8170b32dfce
Fix wrong code for indexed component with very large index type

This fixes an old issue whereby we generate wrong code in Ada for an indexed
component in an array with a ludicrously large index type instead of raising
Storage_Error.  We would need the counterpart of int_const_binop for unop in
the general case, but that's not worth the hassle and int_const_convert is
good enough.

gcc/
PR ada/33994
* fold-const.h (int_const_convert): New prototype.
* fold-const.cc (fold_convert_const_int_from_int): Rename to...
(int_const_convert): ...this, remove static keyword and add third
parameter OVERFLOWABLE.
(fold_convert_const): Call int_const_convert if ARG1 is an integer
constant.

gcc/ada/
PR ada/33994
* gcc-interface/utils.cc (convert) <INTEGER_TYPE>: Call
int_const_convert if the expression is an integer constant.

gcc/testsuite/
* gnat.dg/object_overflow6.adb: New test.
gcc/ada/gcc-interface/utils.cc
gcc/fold-const.cc
gcc/fold-const.h
gcc/testsuite/gnat.dg/object_overflow6.adb [new file with mode: 0644]