[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  <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.

From-SVN: r274301
This commit is contained in:
Bob Duff 2019-08-12 09:01:20 +00:00 committed by Pierre-Marie de Rodat
parent 18ba4b0dbd
commit 39571eeaeb
2 changed files with 7 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2019-08-12 Bob Duff <duff@adacore.com>
* 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 <duff@adacore.com>
* libgnat/a-tifiio.adb (Put_Scaled): Prevent AA from being

View File

@ -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;