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/13490] [gfortran] Compiler rejects valid constant -2147483648 for 32-bit int


------- Additional Comments From coyote at coyotegulch dot com  2003-12-25 19:13 -------
Fortran 95 uses GMP internally, while (as far as I know), the C compiler does
not. The following is a message I posted to the GNU Fortran 95 mailing list a
few minutes ago:

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... 

-- 


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


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