This is the mail archive of the gcc-bugs@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]

[Bug fortran/18597] New: numerical constant arithmetic overflow with integer(kind=4)


This error was encountered in building the NetCDF fortran90 test programme 
with gfortran.

Numerical constants appear to be integer*4 and the +ve and -ve limits are 
fixed to the same magnitude.

PROGRAM test_min
INTEGER(KIND=4),PARAMETER :: ikind=0
integer(kind=4)  :: itest = -HUGE(ikind)-1
print *,-itest
print *,itest-1
END PROGRAM test_min

produces

$ /gcc-4.0/bin/gfortran -O3  test_min.f90
 In file test_min.f90:3

integer(kind=4)  :: itest = -HUGE(ikind)-1PROGRAM test_min
INTEGER(KIND=4),PARAMETER :: ikind=0
integer(kind=4)  :: itest = -HUGE(ikind)    !!!-1 removed
print *,-itest
print *,itest-1
END PROGRAM test_min

                                1
Error: Arithmetic overflow at (1)

whilst


correctly produces

$ ./a
  2147483647
 -2147483648

-- 
           Summary: numerical constant arithmetic overflow with
                    integer(kind=4)
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paul dot richard dot thomas at cea dot fr
                CC: gcc-bugs at gcc dot gnu dot org,paulthomas2 at wanadoo
                    dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18597


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