This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Improve PR30911 and PR31023, Ada and VRP


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]