This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Minimum integer values


I reported the following as a bug, but after reading the gfortran source
code, I'm not entirely certain of my diagnosis.

This program compiles and exceutes with Lahey and Intel compilers, but
*not* with gfortran:

    program parambug
    implicit none

    integer, parameter :: MY_KIND  = SELECTED_INT_KIND(10)
    integer(MY_KIND), parameter :: X = -2147483648

write (*,*) X

end program parambug

The result of compiling with gfortran is:

In file parambug.f90:5

    integer(MY_KIND), parameter :: X = -2147483648
                                             1
    Error: Arithmetic overflow at (1)

Looking at arith.c, I find this comment:

      mpz_init (int_info->min_int);
      mpz_neg (int_info->min_int, int_info->huge);
      /* No -1 here, because the representation is symmetric.  */


Yet I can't find anything in the Fortran 95 standard that supports the contention that potitive and negative values are symmetric (as suggested by the comment.

So is this a bug or not? It certainly is different from other Fortran 95
compilers...

--
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Software Invention for High-Performance Computing




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