Commit a9608b57 by Jerry DeLisle

re PR fortran/36515 (Integer read from stdin yields a value overflow for a valid integer.)

2008-06-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36515
	* libgfortran.h (compile_options_t): Add int range_check to structure.
	* runtime/compile_options.c (set_options): Add range_check option.
	(init_compile_options): Likewise.
	*io/read.c (read_decimal): Change overflow checks to include
	range_check.

From-SVN: r136822
parent a60658ba
2008-06-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/36515
* libgfortran.h (compile_options_t): Add int range_check to structure.
* runtime/compile_options.c (set_options): Add range_check option.
(init_compile_options): Likewise.
*io/read.c (read_decimal): Change overflow checks to include
range_check.
2008-06-13 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2008-06-13 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/36538 PR fortran/36538
......
...@@ -428,13 +428,13 @@ read_decimal (st_parameter_dt *dtp, const fnode *f, char *dest, int length) ...@@ -428,13 +428,13 @@ read_decimal (st_parameter_dt *dtp, const fnode *f, char *dest, int length)
if (c < '0' || c > '9') if (c < '0' || c > '9')
goto bad; goto bad;
if (value > maxv_10) if (value > maxv_10 && compile_options.range_check == 1)
goto overflow; goto overflow;
c -= '0'; c -= '0';
value = 10 * value; value = 10 * value;
if (value > maxv - c) if (value > maxv - c && compile_options.range_check == 1)
goto overflow; goto overflow;
value += c; value += c;
} }
......
...@@ -477,6 +477,7 @@ typedef struct ...@@ -477,6 +477,7 @@ typedef struct
size_t record_marker; size_t record_marker;
int max_subrecord_length; int max_subrecord_length;
int bounds_check; int bounds_check;
int range_check;
} }
compile_options_t; compile_options_t;
......
...@@ -105,6 +105,8 @@ set_options (int num, int options[]) ...@@ -105,6 +105,8 @@ set_options (int num, int options[])
compile_options.sign_zero = options[5]; compile_options.sign_zero = options[5];
if (num >= 7) if (num >= 7)
compile_options.bounds_check = options[6]; compile_options.bounds_check = options[6];
if (num >= 8)
compile_options.range_check = options[7];
/* If backtrace is required, we set signal handlers on most common /* If backtrace is required, we set signal handlers on most common
signals. */ signals. */
...@@ -146,6 +148,7 @@ init_compile_options (void) ...@@ -146,6 +148,7 @@ init_compile_options (void)
compile_options.dump_core = 0; compile_options.dump_core = 0;
compile_options.backtrace = 0; compile_options.backtrace = 0;
compile_options.sign_zero = 1; compile_options.sign_zero = 1;
compile_options.range_check = 1;
} }
/* Function called by the front-end to tell us the /* Function called by the front-end to tell us the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment