[PATCH,committed] Convert assert to runtime error in reading exponents in Fortran
Steve Kargl
sgk@troutmask.apl.washington.edu
Wed Dec 18 23:45:00 GMT 2013
I committed the following changes to gfortran's runtime library.
It converts an assert on an invalid floating-point exponent into
a runtime error.
2013-12-18 Steven G. Kargl <kargl@gcc.gnu.org>
* io/read.c (read_f): Convert assert to runtime error.
2013-12-18 Steven G. Kargl <kargl@gcc.gnu.org>
* gfortran.dg/io_err_1.f90: New test.
Index: libgfortran/io/read.c
===================================================================
--- libgfortran/io/read.c (revision 206100)
+++ libgfortran/io/read.c (working copy)
@@ -1150,7 +1150,9 @@ done:
exponent = - exponent;
}
- assert (exponent < 10000);
+ if (exponent >= 10000)
+ goto bad_float;
+
for (dig = 3; dig >= 0; --dig)
{
out[dig] = (char) ('0' + exponent % 10);
Index: gcc/testsuite/gfortran.dg/io_err_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/io_err_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/io_err_1.f90 (working copy)
@@ -0,0 +1,14 @@
+! { dg-do run }
+! { dg-shouldfail "Compile-time specifier checking" }
+!
+! Contributed by Dominique Dhumieres <dominiq at lps dot ens dot fr>
+program read
+ character(50) :: buf='0.D99999'
+ double precision val
+ read (UNIT=buf, FMT='(D60.0)', ERR=10) Val
+ call abort
+10 read (UNIT=buf, FMT='(D60.0)') Val
+end program read
+! { dg-output "At line 10 of file.*" }
+! { dg-output "Fortran runtime error: Bad value during floating point read" }
+
--
Steve
More information about the Fortran
mailing list