[Bug fortran/36515] Integer read from stdin yields a value overflow for a valid integer.
kargl at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Jun 13 03:26:00 GMT 2008
------- 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
More information about the Gcc-bugs
mailing list