public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int
@ 2003-12-25 18:23 coyote at coyotegulch dot com
2003-12-25 19:13 ` [Bug fortran/13490] " coyote at coyotegulch dot com
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2003-12-25 18:23 UTC (permalink / raw)
To: gcc-bugs
The attached program compiles and runs correctly with Intel Fortran 95 8.0 and
Lahey Fortran 95 6.1, but generates an error with gfortran. The error is:
In file parambug.f90:5
integer(MY_KIND), parameter :: X = -2147483648
1
Error: Arithmetic overflow at (1)
--
Summary: Compiler rejects valid constant -2147483648 for 32-bit
int
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: coyote at coyotegulch dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux
GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
@ 2003-12-25 19:13 ` coyote at coyotegulch dot com
2003-12-25 20:48 ` [Bug fortran/13490] [gfortran] " pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2003-12-25 19:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From coyote at coyotegulch dot com 2003-12-25 17:52 -------
Created an attachment (id=5370)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5370&action=view)
An example the gfortran can't compile
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] [gfortran] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
2003-12-25 19:13 ` [Bug fortran/13490] " coyote at coyotegulch dot com
@ 2003-12-25 20:48 ` pinskia at gcc dot gnu dot org
2003-12-25 21:10 ` coyote at coyotegulch dot com
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-25 20:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-12-25 17:54 -------
Most likely what is happening is also happens in C that 2147483648 has to defined as an unsigned
and then the negative is applied causing this error.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Summary|Compiler rejects valid |[gfortran] Compiler rejects
|constant -2147483648 for 32-|valid constant -2147483648
|bit int |for 32-bit int
Target Milestone|--- |tree-ssa
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] [gfortran] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
2003-12-25 19:13 ` [Bug fortran/13490] " coyote at coyotegulch dot com
2003-12-25 20:48 ` [Bug fortran/13490] [gfortran] " pinskia at gcc dot gnu dot org
@ 2003-12-25 21:10 ` coyote at coyotegulch dot com
2003-12-26 16:31 ` pbrook at gcc dot gnu dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2003-12-25 21:10 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] [gfortran] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (2 preceding siblings ...)
2003-12-25 21:10 ` coyote at coyotegulch dot com
@ 2003-12-26 16:31 ` pbrook at gcc dot gnu dot org
2003-12-26 19:37 ` coyote at coyotegulch dot com
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pbrook at gcc dot gnu dot org @ 2003-12-26 16:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pbrook at gcc dot gnu dot org 2003-12-26 15:25 -------
See
http://gcc.gnu.org/ml/fortran/2003-12/msg00082.html
Relevant section of (draft) F95 standard is 13.7.1
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-12-26 15:25:51
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] [gfortran] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (3 preceding siblings ...)
2003-12-26 16:31 ` pbrook at gcc dot gnu dot org
@ 2003-12-26 19:37 ` coyote at coyotegulch dot com
2004-05-26 11:47 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2003-12-26 19:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From coyote at coyotegulch dot com 2003-12-26 19:01 -------
gfortran is behaving correctly according to the Standard.
In reflection of interoperability needs, I've posted a patch to pcc-patches that
implements a new flag, -fasymmetrical-integers. This flag tells gfortran to
accept integers in the range [-n-1,n], whereas the standard requires the range
[-n,n].
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] [gfortran] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (4 preceding siblings ...)
2003-12-26 19:37 ` coyote at coyotegulch dot com
@ 2004-05-26 11:47 ` pinskia at gcc dot gnu dot org
2004-07-13 16:23 ` [Bug fortran/13490] " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-26 11:47 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.5.0 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (5 preceding siblings ...)
2004-05-26 11:47 ` pinskia at gcc dot gnu dot org
@ 2004-07-13 16:23 ` pinskia at gcc dot gnu dot org
2004-10-19 18:49 ` coyote at coyotegulch dot com
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-13 16:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-13 16:23 -------
*** Bug 16512 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |billingd at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (6 preceding siblings ...)
2004-07-13 16:23 ` [Bug fortran/13490] " pinskia at gcc dot gnu dot org
@ 2004-10-19 18:49 ` coyote at coyotegulch dot com
2004-10-19 19:15 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2004-10-19 18:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From coyote at coyotegulch dot com 2004-10-19 18:49 -------
Posted a slightly revised patch, ten months after the first.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (7 preceding siblings ...)
2004-10-19 18:49 ` coyote at coyotegulch dot com
@ 2004-10-19 19:15 ` pinskia at gcc dot gnu dot org
2004-10-22 0:05 ` coyote at coyotegulch dot com
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-19 19:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-19 19:15 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01613.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (8 preceding siblings ...)
2004-10-19 19:15 ` pinskia at gcc dot gnu dot org
@ 2004-10-22 0:05 ` coyote at coyotegulch dot com
2004-10-28 21:45 ` coyote at coyotegulch dot com
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2004-10-22 0:05 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
------- Additional Comments From coyote at coyotegulch dot com 2004-10-22 00:05 -------
When this topic came up last year, I was in favor of gfortran working like other
Fortran 95 compilers, which accept minimum integer values of -(2**(n-1)).
Several Fortran language lawyers insisted that the default behavior should be to
reject such values, as they are not symmetrical across ABS() (a requirement
implied by the Standard.)
My previous patches for this problem have catered to the language lawyers by
adding a switch to enable "asymmetric" integers. I never liked doing it that way.
After a discussion with Tobias Schlüter, I've decided to present the following
patch, which causes gfortran to behave exactly like other Fortran 95 compilers.
For a -pedantic compile, gfortran will now display a warning about a potential
Standard violation.
This patch gives me warm fuzzies. The gods only know what the language lawyers
will think... :)
Bootstrapped and tested on i686-pc-linux and x86_64-pc-linux.
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01876.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (9 preceding siblings ...)
2004-10-22 0:05 ` coyote at coyotegulch dot com
@ 2004-10-28 21:45 ` coyote at coyotegulch dot com
2004-10-28 21:48 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: coyote at coyotegulch dot com @ 2004-10-28 21:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From coyote at coyotegulch dot com 2004-10-28 21:45 -------
Patch committed after approval
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (10 preceding siblings ...)
2004-10-28 21:45 ` coyote at coyotegulch dot com
@ 2004-10-28 21:48 ` pinskia at gcc dot gnu dot org
2004-10-28 22:25 ` cvs-commit at gcc dot gnu dot org
2004-10-29 4:41 ` cvs-commit at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-28 21:48 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (11 preceding siblings ...)
2004-10-28 21:48 ` pinskia at gcc dot gnu dot org
@ 2004-10-28 22:25 ` cvs-commit at gcc dot gnu dot org
2004-10-29 4:41 ` cvs-commit at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-28 22:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-10-28 22:25 -------
Subject: Bug 13490
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: srladd@gcc.gnu.org 2004-10-28 22:25:18
Modified files:
gcc/fortran : ChangeLog
Log message:
Fix for PR fortran/13490, PR fortran/17912
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.239&r2=1.240
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/13490] Compiler rejects valid constant -2147483648 for 32-bit int
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
` (12 preceding siblings ...)
2004-10-28 22:25 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-29 4:41 ` cvs-commit at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-29 4:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-10-29 04:41 -------
Subject: Bug 13490
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: billingd@gcc.gnu.org 2004-10-29 04:41:49
Modified files:
gcc/testsuite : ChangeLog
gcc/testsuite/gfortran.dg/g77: 20030326-1.f README
Log message:
2004-10-29 David Billinghurst <David.Billinghurst@riotinto.com>
PR fortran/13490
* gfortran.dg/g77/20030326-1.f: Change xfail on error to warning.
* gfortran.dg/g77/README: Update.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4516&r2=1.4517
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/g77/20030326-1.f.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/g77/README.diff?cvsroot=gcc&r1=1.6&r2=1.7
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13490
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2004-10-29 4:41 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-25 18:23 [Bug fortran/13490] New: Compiler rejects valid constant -2147483648 for 32-bit int coyote at coyotegulch dot com
2003-12-25 19:13 ` [Bug fortran/13490] " coyote at coyotegulch dot com
2003-12-25 20:48 ` [Bug fortran/13490] [gfortran] " pinskia at gcc dot gnu dot org
2003-12-25 21:10 ` coyote at coyotegulch dot com
2003-12-26 16:31 ` pbrook at gcc dot gnu dot org
2003-12-26 19:37 ` coyote at coyotegulch dot com
2004-05-26 11:47 ` pinskia at gcc dot gnu dot org
2004-07-13 16:23 ` [Bug fortran/13490] " pinskia at gcc dot gnu dot org
2004-10-19 18:49 ` coyote at coyotegulch dot com
2004-10-19 19:15 ` pinskia at gcc dot gnu dot org
2004-10-22 0:05 ` coyote at coyotegulch dot com
2004-10-28 21:45 ` coyote at coyotegulch dot com
2004-10-28 21:48 ` pinskia at gcc dot gnu dot org
2004-10-28 22:25 ` cvs-commit at gcc dot gnu dot org
2004-10-29 4:41 ` cvs-commit at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).