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, libfortran]: PR34411 hang-up during read of non-expected input


:ADDPATCH fortran:

Hi All,

Gfortran's behavior for the program listed in the PR is standard conforming now. With this patch, we provide a little bit better error recovery capability by advancing to the next record (end-of-line) in the case of a bad formatted read.

This mimics Intel ifort and Sun sf95 behavior. (including the test case provided)

Regression tested on x86-64-linux-gnu.

OK for trunk? (Its a trivial patch, but I thought I would ask)

Best regards,

Jerry

2007-12-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libfortran/34411
	* io/read.c (convert_real, read_l, read_decimal, read_radix, read_f):
	Call next_record after bad read or overflow error.
Index: io/read.c
===================================================================
--- io/read.c	(revision 130717)
+++ io/read.c	(working copy)
@@ -177,6 +177,7 @@ convert_real (st_parameter_dt *dtp, void
     {
       generate_error (&dtp->common, LIBERROR_READ_VALUE,
 		      "Error during floating point read");
+      next_record (dtp, 1);
       return 1;
     }
 
@@ -225,6 +226,7 @@ read_l (st_parameter_dt *dtp, const fnod
     bad:
       generate_error (&dtp->common, LIBERROR_READ_VALUE,
 		      "Bad value on logical read");
+      next_record (dtp, 1);
       break;
     }
 }
@@ -395,11 +397,13 @@ read_decimal (st_parameter_dt *dtp, cons
  bad:
   generate_error (&dtp->common, LIBERROR_READ_VALUE,
 		  "Bad value during integer read");
+  next_record (dtp, 1);
   return;
 
  overflow:
   generate_error (&dtp->common, LIBERROR_READ_OVERFLOW,
 		  "Value overflowed during integer read");
+  next_record (dtp, 1);
   return;
 }
 
@@ -539,11 +543,13 @@ read_radix (st_parameter_dt *dtp, const 
  bad:
   generate_error (&dtp->common, LIBERROR_READ_VALUE,
 		  "Bad value during integer read");
+  next_record (dtp, 1);
   return;
 
  overflow:
   generate_error (&dtp->common, LIBERROR_READ_OVERFLOW,
 		  "Value overflowed during integer read");
+  next_record (dtp, 1);
   return;
 }
 
@@ -659,6 +665,7 @@ read_f (st_parameter_dt *dtp, const fnod
  bad_float:
   generate_error (&dtp->common, LIBERROR_READ_VALUE,
 		  "Bad value during floating point read");
+  next_record (dtp, 1);
   return;
 
   /* The value read is zero */
! { dg-do run }
! PR34411 hang-up during read of non-expected input
! Test case derived from that given in PR
! Prior to patch, the do loop was infinite, limits set in this one
program pr34411
  real :: x,y
  ii = 0
  iostat = 0
  x = 0.0; y= 0.0
  open (10, status="scratch")
  write (10, '(a)')" 289  329.142  214.107   12.313   12.050   11.913   11.868"
  write (10, '(a)')"  2038.497 99.99  0.00   0.019    0.021    0.025    0.034"
  write (10, '(a)')""
  write (10, '(a)')" 413  360.334  245.261   12.375   11.910   11.469   11.086"
  write (10, '(a)')"  2596.395 99.99  0.00   0.019    0.017    0.016    0.015" 
  write (10, '(a)')""
  write (10, '(a)')" 655  332.704  317.964   12.523   12.212   11.998   11.892"
  write (10, '(a)')"  1627.586 99.99  0.00   0.005    0.005    0.006    0.007"
  write (10, '(a)')""
  write (10, '(a)')" 360  379.769  231.226   12.709   12.422   12.195   11.941"
  write (10, '(a)')"  2561.539 99.99  0.00   0.042    0.043    0.050    0.055"
  rewind 10
  do i = 1,100
     read(10,'(T7,2F9.3)', iostat=ii, end=666) x,y
  end do
666 continue
  if (i /= 12) call abort
  if (x /= 379.76901 .and. y /= 231.22600) call abort
  close(10)
end program pr34411

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