This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/36515] Integer read from stdin yields a value overflow for a valid integer.
- From: "kargl at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jun 2008 03:25:58 -0000
- Subject: [Bug fortran/36515] Integer read from stdin yields a value overflow for a valid integer.
- References: <bug-36515-12036@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from kargl at gcc dot gnu dot org 2008-06-13 03:25 -------
(In reply to comment #3)
> There is no "proper" way.
>
> Use -2147483647 which is the most negative integer representable in 32 bits.
>
This isn't necessarily true. :)
There are a few options.
1) Add -fno-range-check to the options that are provided to the runtime
library. Then in io/read.c (as well as other files), we could change
line 397 from
if (value > maxv_10)
goto overflow;
to
if (value > maxv_10 && !compile_option.range_check)
goto overflow;
2) The other option would be to special case the -huge()-1
case in the runtime library. I haven't looked closely
enough to see if it would work, but the above could be
changed to
/* Catch values larger than huge(). */
if (!negative && value > maxv_10)
goto overflow;
/* Catch values less than -huge()-1 */
if (negative && value > maxv_10 + PLUS_WHATEVER_IS_NEEDED_HERE)
goto overflow;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36515