diff mbox series

[Ada] Use correct subtype for call to Last in formal vectors

Message ID 20191212100430.GA114671@adacore.com
State New
Headers show
Series [Ada] Use correct subtype for call to Last in formal vectors | expand

Commit Message

Pierre-Marie de Rodat Dec. 12, 2019, 10:04 a.m. UTC
Correct the subtype used for a call to Last in Find_Index so that it no
longer crashes on empty vectors with checks enabled.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-12-12  Claire Dross  <dross@adacore.com>

gcc/ada/

	* libgnat/a-cofove.adb, libgnat/a-cfinve.adb (Find_Index): Use
	Extended_Index for call to Last.
diff mbox series

Patch

--- gcc/ada/libgnat/a-cfinve.adb
+++ gcc/ada/libgnat/a-cfinve.adb
@@ -458,7 +458,7 @@  is
       Index     : Index_Type := Index_Type'First) return Extended_Index
    is
       K    : Count_Type;
-      Last : constant Index_Type := Last_Index (Container);
+      Last : constant Extended_Index := Last_Index (Container);
 
    begin
       K := Capacity_Range (Int (Index) - Int (No_Index));

--- gcc/ada/libgnat/a-cofove.adb
+++ gcc/ada/libgnat/a-cofove.adb
@@ -379,7 +379,7 @@  is
       Index     : Index_Type := Index_Type'First) return Extended_Index
    is
       K    : Count_Type;
-      Last : constant Index_Type := Last_Index (Container);
+      Last : constant Extended_Index := Last_Index (Container);
 
    begin
       K := Capacity_Range (Int (Index) - Int (No_Index));