Bug 17912 - gfortran: Bogus "Arithmetic overflow" error, regression w.r.t. g77
Summary: gfortran: Bogus "Arithmetic overflow" error, regression w.r.t. g77
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: patch, rejects-valid
: 18597 (view as bug list)
Depends on: 13490
Blocks:
  Show dependency treegraph
 
Reported: 2004-10-09 16:19 UTC by Harald Anlauf
Modified: 2004-11-21 16:19 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-10-09 18:37:37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2004-10-09 16:19:12 UTC
Hi,

this code fails to compile with gfortran, but compiles with g77
(and, needless to say, other compilers ;-)

      program gfcbug16
      integer i
      i = -2147483647 - 1
      print *, i
      end

I get:

 In file gfcbug16.f:3

      i = -2147483647 - 1                                               
         1
Error: Arithmetic overflow at (1)


Note that the integer constants are perfectly legal (so this is different
from bug report #13490), but gfortran sort of "optimizes" by calculating
the difference and then complains, even if compiling with -O0 -g.

I could live with a (suppressible) warning message, but throwing an error
clearly breaks legacy code.

Cheers,
-ha
Comment 1 Andrew Pinski 2004-10-09 18:37:37 UTC
Confirmed.
Comment 2 Tobias Schlüter 2004-10-11 16:28:50 UTC
This has been a topic of heated discussion in the past. See the bug I added as a
dependency and the various discussions this had spawned. I think as I always
thought that we're safe from the point of view of the standard to allow integer
ranges [-2**31, 2**31-1], and now that the dust has settled I think a patch for
this can be proposed again.

I'll cook something up these days.
Comment 3 Scott Robert Ladd 2004-10-19 18:54:46 UTC
I've posted an update to the original "asymmetric integers" patch, but it did
not address this specific PR.
Comment 4 Scott Robert Ladd 2004-10-19 19:06:58 UTC
Correction: My patch does fix this bug. See:

http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01613.html
Comment 5 Scott Robert Ladd 2004-10-22 00:07:02 UTC
An improved patch. See comments attached to PR13490, or the patch below:

http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01876.html
Comment 6 Scott Robert Ladd 2004-10-28 21:46:19 UTC
Patch committed after approval
Comment 7 Andrew Pinski 2004-10-28 21:48:28 UTC
Fixed.
Comment 8 CVS Commits 2004-10-28 22:25:22 UTC
Subject: Bug 17912

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

Comment 9 Andrew Pinski 2004-11-21 16:19:11 UTC
*** Bug 18597 has been marked as a duplicate of this bug. ***