Small error in range check?

Arjen Markus arjen.markus895@gmail.com
Thu Dec 12 14:20:00 GMT 2013


Hello,

I ran into a slight problem regarding one-byte integers. The program
below illustrates it:

! chkbyte.f90 --
!     Check the range for an integer of one byte
!     This ought to be from -128 to +127
!
program chkbyte
    implicit none

    integer, parameter :: byte = 1
    integer(kind=byte) :: var

    var = -128_byte

    write(*,*) var
end program chkbyte

The gfortran compiler (I tried with 4.5, 4.7 and 4.8) does not like
the value of -128 for such integers.
As far as I know the range for such integers is -128 to 127 and if I
turn off the range checking, the variable is indeed set to -128.

Shall I create a bug report for this one? I did not find anything
similar in the bug list.

Regards,

Arjen



More information about the Fortran mailing list