Bug 33001 - error with hexadecimal DATA
Summary: error with hexadecimal DATA
Status: RESOLVED DUPLICATE of bug 18026
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-06 11:01 UTC by sliwa@cft.edu.pl
Modified: 2007-08-06 17:30 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
sample source that does not compile (1.62 KB, text/x-fortran)
2007-08-06 11:03 UTC, sliwa@cft.edu.pl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sliwa@cft.edu.pl 2007-08-06 11:01:58 UTC
d1mach.f:90.43:

      DATA LARGE(1), LARGE(2) / Z'FFFFFFFF', Z'7FEFFFFF' /              
                                          1
Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) at (1)
Comment 1 sliwa@cft.edu.pl 2007-08-06 11:03:32 UTC
Created attachment 14028 [details]
sample source that does not compile

This is a SLATEC machine file
Comment 2 Tobias Burnus 2007-08-06 12:11:39 UTC
      DATA LARGE(1), LARGE(2) / Z'FFFFFFFF', Z'7FEFFFFF' /              
Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) at (1)

The error message is correct: You cannot fit the number into an INTEGER(4) as this is bigger than "HUGE(0)".

As the overflow is intended, one can use   -fno-range-check   to disable this checking and thus the error message.

I think one should do here the same as in primary.c and add the following to the error message:

--- arith.c     (revision 127237)
+++ arith.c     (working copy)
@@ -1983,3 +1983,4 @@ arith_error (arith rc, gfc_typespec *fro
     case ARITH_OVERFLOW:
-      gfc_error ("Arithmetic overflow converting %s to %s at %L",
+      gfc_error ("Arithmetic overflow converting %s to %s at %L. This check "
+                "can be disabled with the option -fno-range-check",
                 gfc_typename (from), gfc_typename (to), where);
Comment 3 sliwa@cft.edu.pl 2007-08-06 12:41:29 UTC
1. The attached d1mach.f works fine with g77.

2. The numbers are 32-bit, so why an overflow? Maybe the number is extended as a signed number (padded with ones), and the conversion is unsigned.

Comment 4 sliwa@cft.edu.pl 2007-08-06 12:45:05 UTC
With -fno-range-check I get:

d1mach.f: In function 'd1mach':
d1mach.f:2: fatal error: gfc_todo: Not Implemented: Initialization of overlapping variables
compilation terminated.

See also bug #33002.

Comment 5 Tobias Burnus 2007-08-06 13:06:27 UTC
> The numbers are 32-bit, so why an overflow?
     huge(0): 2147483647 ! biggest (positive) number fitting into integer(4)
 Z'FFFFFFFF': 4294967295

I would argue that 4294967295 is bigger than 2147483647. If one allows the overflow or regards it as bit pattern, one obtains "-1". This is also what one gets for -fno-range-check.

The program is simply invalid though as vendor extension many compilers allow it. One can discuss about the default behaviour in gfortran [write to the mailing list and not here], but the current behaviour has some merits, though I think one should point to the option which allows the compilation (see patch in comment #2).

-------------

(In reply to comment #4)
> d1mach.f:2: fatal error: gfc_todo: Not Implemented: Initialization of
> overlapping variables

This was fixed meanwhile. gfortran 4.3 does not have this error any more.
4.3 binaries are available at:  http://gcc.gnu.org/wiki/GFortranBinaries
Comment 6 kargls 2007-08-06 17:30:22 UTC

*** This bug has been marked as a duplicate of 18026 ***
Comment 7 patchapp@dberlin.org 2007-08-06 18:20:30 UTC
Subject: Bug number PR33001

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00374.html
Comment 8 Tobias Burnus 2007-08-09 21:28:08 UTC
Subject: Bug 33001

Author: burnus
Date: Thu Aug  9 21:27:52 2007
New Revision: 127321

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127321
Log:
2007-08-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/33001
	* arith.c (arith_error): Point in the error message
	to -fno-range-check.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/arith.c