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, libgfortran] PR31366 last record truncated for read after short write, direct access file


:ADDPATCH fortran:

The attached patch was approved off list in IRC by Thomas. I will commit to 4.3 soon, along with the test case. The patch is trivial and consistent with comments received on c.l.f .

Regression tested on x86-64-Gnu/Linux

Regards,

Jerry

2007-04-01 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/31366
	* io/transfer.c (read_block_direct): Do not generate error when reading
	past EOF on a short record that is less than the RECL= speified.
Index: transfer.c
===================================================================
*** transfer.c	(revision 123355)
--- transfer.c	(working copy)
*************** read_block_direct (st_parameter_dt *dtp,
*** 411,417 ****
  	  /* Short read, e.g. if we hit EOF.  Apparently, we read
  	   more than was written to the last record.  */
  	  *nbytes = to_read_record;
- 	  generate_error (&dtp->common, ERROR_SHORT_RECORD, NULL);
  	  return;
  	}
  
--- 411,416 ----
! { dg-do run }
! pr31366 last record truncated for read after short write, direct access file.
! test case derived from pr, submitted by jerry delisle  <jvdelisle@gcc.gnu.org
      program test
      character(len=8) :: as_written, as_read
      character(1) :: byte
      as_written = "12345678"
      open (76, access="direct", recl=12, status="scratch")
      write(76, rec=1) as_written
      write(76, rec=2) as_written
      read(76, rec=1) as_read, byte, byte, byte, byte
      read(76, rec=2, err=3) as_read, byte, byte, byte, byte
      stop
  3   call abort()
      end program test


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