]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Array aggregate with large static bounds causes compiler crash
authorSteve Baird <baird@adacore.com>
Wed, 30 Oct 2024 22:34:50 +0000 (15:34 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 18 Nov 2024 14:06:54 +0000 (15:06 +0100)
In some cases an array aggregate with statically known bounds and at least
one bound outside of the range of a 32-bit signed integer causes
a bugbox.

gcc/ada/ChangeLog:

* exp_aggr.adb (Convert_To_Positional.Flatten): Avoid raising
Constraint_Error in UI_To_Int by testing UI_Is_In_Int_Range first.

gcc/ada/exp_aggr.adb

index c63d22b58fa48923f5156280be17c14a5d1a0b99..1cfc97b5bc6f1aaa3a0b9a3b22fbf6fa0c4fce9f 100644 (file)
@@ -4509,6 +4509,11 @@ package body Exp_Aggr is
             return False;
          end if;
 
+         if not (UI_Is_In_Int_Range (Lov) and UI_Is_In_Int_Range (Hiv)) then
+            --  guard against raising C_E in UI_To_Int
+            return False;
+         end if;
+
          --  Determine if set of alternatives is suitable for conversion and
          --  build an array containing the values in sequence.