[patch, fortran] PR 30381, PR 30420: Fix constant-folding in bitwise intrinsics

Brooks Moses brooks.moses@codesourcery.com
Wed Jan 10 05:32:00 GMT 2007


Brooks Moses wrote:
> 2007-01-09  Brooks Moses  <brooks.moses@codesourcery.com>
> 
> 	* chkbits.f90: Added IBCLR tests; test calls for
> 	different integer kinds.
> 	* ishft.f90: Renamed to ishft_1.f90...
> 	* ishft_1.f90: ...Renamed from ishft.f90.
> 	* ishft_2.f90: New test.
> 	* ishft_3.f90: New test.
> ------------------------------------------------------------------------
> 
> ! { dg-do run }
> program ishft_2
>   if ( ishftc(3, 2, 3) /= 5 ) call abort()
>   if ( ishftc(256+3, 2, 3) /= 256+5 ) call abort()
>   if ( ishftc(1_4, 31) /= (-huge(1_4) - 1) ) call abort()
> end program

I sent the wrong version of this test file -- that last line should be:

   if ( ishftc(1_4, 31) + 1 /= -huge(1_4) ) call abort()

Otherwise, with --pedantic, a warning is thrown about (-huge(1_4) - 1) 
being outside the symmetric range.

(I'm not at all convinced that this warning should be enabled unless 
someone specifically asks for it, but that's a separate issue.)

- Brooks



More information about the Fortran mailing list