Anyone disagree that the two values marked “wrong” returned by gfortran 10.3.0 are wrong?
Getting ready to file a bug report if agreed (have not tested with newer versions yet, though).
My conjecture in the following code is all returned values from BGE()
should be .true. except for the oversized value which it would be nice
to get a warning for, if not an error.
ifort 2021.3.0 20210609 produces the answers I expect, but gfortran
10.3.0. compiler does not. Results from any other compiler family would be appreciated.
> 1000000000000000000000000000000000000000000000000000000000000000
> 1
> T
> T
> T
> T
> T
> F <-- wrong
> F <-- wrong
> T
> T
> T
> F <-- should not do, but would like warning
My read of the standard is that the shorter variable should have 0 bits
padded on the left till it is the length of the longer variable up to
the number of bits in the biggest bitsize any integer type has, but
gfortran seems to truncate the BOZ content to the rightmost number of
bits that matches the kind of any integer present, much like is done
with other bit-level routines that return numeric values (as opposed to
logical).
Fortran source
program demo_bge
use,intrinsic :: iso_fortran_env, only : int8, int16, int32, int64
implicit none
integer(kind=int8) :: byte
integer(kind=int64) :: big
big=-huge(big)-1
byte=1
write(*,'(b0)')big, byte
! ok with integers
write(*,*)bge(big,1_int8) ! T
write(*,*)bge(big,1_int16) ! T
write(*,*)bge(big,1_int32) ! T
write(*,*)bge(big,1_int64) ! T
! appears to be truncating BOZ literal constant number of bits
! of other argument(?)
write(*,*)bge( b'10000000', byte) ! T
write(*,*)bge( b'100000000', byte) ! T
write(*,*)bge( b'100000000000000000000000000000000', 1) ! T
! two constants
! not sure why you would want to, but does not appear prohibited
write(*,*)bge( b'10000000', b'00000001') ! T
write(*,*)bge( b'100000000', b'00000001') ! T
write(*,*)bge( b'10000000000000000000000000000000', b'00000001') ! T
! any warning about size exceeded?
!$ ifndef INTEL
write(*,*)bge( b'10000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&000000000000000000000000000000000000000000000000000000000000000&
&0000000000000000000000000000000000000000000000001', b'00000011') ! T
!$endif
end program demo_bge