[PATCH] Improve PR30911 and PR31023, Ada and VRP
Arnaud Charlet
charlet@adacore.com
Tue Apr 1 07:43:00 GMT 2008
> package Values is
>
> type Range_Type is range 1 .. 2;
> for Range_Type'Size use 8;
>
> function Is_Valid (X : Range_Type) return Boolean;
>
> end;
>
> package body Values is
>
> function Is_Valid (X : Range_Type) return Boolean is
> begin
> case Integer(X) is
> when 1 => return True;
> when 2 => return True;
> when others => return False;
> end case;
> end;
>
> end;
>
> is optimized to "return True;" at -O, so there won't be any quantum leap.
The above looks wrong to me: the RM has specific provision for requiring a
check in the case of "case statements", so the above case statement should
not be optimized to "return True" as far as I know.
Robert, could you confirm ?
Arno
More information about the Gcc-patches
mailing list