diff mbox series

[Ada] Prevent crash in Is_Reachable

Message ID 20190812090251.GA22670@adacore.com
State New
Headers show
Series [Ada] Prevent crash in Is_Reachable | expand

Commit Message

Pierre-Marie de Rodat Aug. 12, 2019, 9:02 a.m. UTC
This patch fixes a bug in Is_Reachable, which causes a crash when checks
are on.

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

2019-08-12  Bob Duff  <duff@adacore.com>

gcc/ada/

	* libgnat/a-cbmutr.adb (Is_Reachable): Declare Idx to be of the
	base subtype.  Clearly it makes no sense to loop "while Idx >=
	0", if Idx is of a nonnegative subtype.
diff mbox series

Patch

--- gcc/ada/libgnat/a-cbmutr.adb
+++ gcc/ada/libgnat/a-cbmutr.adb
@@ -1767,10 +1767,8 @@  package body Ada.Containers.Bounded_Multiway_Trees is
      (Container : Tree;
       From, To  : Count_Type) return Boolean
    is
-      Idx : Count_Type;
-
+      Idx : Count_Type'Base := From;
    begin
-      Idx := From;
       while Idx >= 0 loop
          if Idx = To then
             return True;