[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #7 from pinskia at gcc dot gnu dot org 2007-02-27 21:50 --- *** Bug 30985 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||burnus at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580
[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #6 from kloedej at knmi dot nl 2006-10-31 08:25 --- A short additional remark on this item: I just learned (thanks to Paul Poli) that the NAGware f95 compiler does behave in the same way as gfortran, i.e. refusing to compile the constant -2147483648 in: integer(KIND=4) :: i i=-2147483648 an alternative formulation for the mentioned simple workaround (not using huge()) that does work for all compilers I know is: integer(KIND=4) :: i i=-2147483647 -1 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580
[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #5 from kloedej at knmi dot nl 2006-10-25 07:16 --- Thanks for your additional explanation, and the link to the original mail in the mailing list. A last remark on my side is then about the actual text of this error message. People not familiar with the choice made in the fortran standard to handle the minus here as a unary operator will still be puzzled (like I was) by a message like: i=-2147483648 1 Error: Integer too big for its kind at (1) Maybe it is possible to make the error message a bit more verbose, like: i=-2147483648 1 Error: Integer 2147483648 in unary_minus(2147483648) at (1) too big for its kind This way it is clear to everybody how it is implemented and what is happening. best regards, Jos. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580
[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #1 from kargl at gcc dot gnu dot org 2006-10-24 14:47 --- It is not a bug. i = - 2147483648 is a unary minus operation on the number 2147483648. This number overflows the range. If you want the most negative number for an integer use i = - huge(i) - 1. I've already pointed you the to the commit that fixed range checking. There is a very long email in the fortran@ mailing list that explains the problem and why it was fixed. -- kargl at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580
[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #2 from kloedej at knmi dot nl 2006-10-24 15:04 --- In my simple view as a physicist the minus sign is an integral part of the number and not an operation on it, but then I didn't have a formal computer science education. As a gfortran programmer you have a choice here I would say. Just note that you can expect a lot of complaints about this behaviour, since all other compilers that I regularly use (ifort, g95, pgf90) accept -2147483648 as a proper 4 byte integer constant without any warnings. Also note that I was not able to find the mail you refer to on the gfortran mailing list. Searching on -2147483648 yields nothing, and there is way to much noise to find it by browsing through the list. best regards, Jos de Kloe -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580
[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #3 from kargl at gcc dot gnu dot org 2006-10-24 15:25 --- (In reply to comment #2) In my simple view as a physicist the minus sign is an integral part of the number and not an operation on it, but then I didn't have a formal computer science education. As a gfortran programmer you have a choice here I would say. You'll find that I'm a physicist, too. I have no formal CS training other than reading books and the Fortran standard. It does not matter if you consider the minus a part of the number. It is a unary minus operation according to the Fortran Standard, and that is how gfortran implements its behavior. You are relying on nonportable processor dependent behavior. I've told you how to make your code portable. It is up to you to use the advice or ignore it. BTW, http://gcc.gnu.org/ml/fortran/2006-08/msg00371.html -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580
[Bug fortran/29580] integer -2147483648 out of range: bug or feature?
--- Comment #4 from pinskia at gcc dot gnu dot org 2006-10-24 15:57 --- You should note that C has the same issue really. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29580