From 39571eeaeb6e993f259cc603c64d5483be5afc65 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Mon, 12 Aug 2019 09:01:20 +0000 Subject: [PATCH] [Ada] Prevent crash in Is_Reachable This patch fixes a bug in Is_Reachable, which causes a crash when checks are on. 2019-08-12 Bob Duff 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. From-SVN: r274301 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/libgnat/a-cbmutr.adb | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 97f31414639..4922e46ff54 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-08-12 Bob Duff + + * 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. + 2019-08-12 Bob Duff * libgnat/a-tifiio.adb (Put_Scaled): Prevent AA from being diff --git a/gcc/ada/libgnat/a-cbmutr.adb b/gcc/ada/libgnat/a-cbmutr.adb index cdc26296d2c..fb8585a100f 100644 --- a/gcc/ada/libgnat/a-cbmutr.adb +++ b/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; -- 2.30.2