nncarlson / gfortran.dg

The GFortran testsuite rigged for testing other Fortran compilers
7 stars 2 forks source link

mvbits_1.f90: undefined behavior of 2_N**(N*8) #28

Open vzakhari opened 1 year ago

vzakhari commented 1 year ago

https://github.com/nncarlson/gfortran.dg/blob/master/mvbits_1.f90 uses the following computations:

ibits=bit_size(1_4)
do n=1,ibits
   i4=-1
   call mvbits(1_4, 0,n,i4,0)
   j4=-1-2_4**n+2
   if(i4.ne.j4)STOP 3
enddo

For example for kind*4, n goes up to 32, so 2_4**32 overflows. NVHPC compiler computes j4 into 0 in this case, while the mvbits result in i4 is 1.

vzakhari commented 1 year ago

nag-7.0 also computes j4 to 0 in this case.