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)
Created attachment 14028 [details] sample source that does not compile This is a SLATEC machine file
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);
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.
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.
> 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
*** This bug has been marked as a duplicate of 18026 ***
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
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