This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] fortran/29147 -- Disable integer range checking.


Against my better judgement, I've produced the attached
patch to disable integer range checking.  This patch allows 
gfortran to compile code as the programmer intended not as
the programmer wrote!  Consider,

    program a
    integer(4) b
    data b /Z'FFFFFFFF'/
    end program

where gfortran supports an integer(4) and an integer(8) type.
The standard explicitly states that the BOZ is converted 
to an integer with a kind type parameter with the largest
decimal range.  So, the BOZ above becomes 4294967295, which
overflows a 32-bit (signed) integer(4) type.  On a twos-compliment
OS without range checking, the value of b would be -1 due
to the usual wrap around.  Unfortunately, some programmers
have come to depend on the nonportable, processor-dependent,
behavior.  Therefore, a gfortran user will need to explicitly
request no range checking via the -fno-range-check option.

Regression tested on amd64-*-freebsd.  There were no new
regressions.

OK for trunk and 4.1?  (It's borderline "obviously correct").

2006-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/29147
	* arith.c (gfc_check_integer_range):  Disable range checking via
	-fno-range-check.

-- 
Steve

Attachment: pr29147.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]