[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    [patch,libgfortran] PR25550 file data corrupted after reading end of  file.
From:       Jerry DeLisle <jvdelisle () verizon ! net>
Date:       2005-12-27 4:37:52
Message-ID: 43B0C520.9000700 () verizon ! net
[Download RAW message or body]

:ADDPATCH fortran:

The below patch is "simple and maybe not so obvious" but it fixes the problem!

Will commit in 24 hours unless otherwise notified to trunk, and then to 4.1 a 
bit later.

NIST tested, regression tested.

2005-12-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25550
	* io/file_pos.c (st_rewind): Reset bytes left so no error occurs in
	next_record_r.

Index: io/file_pos.c
===================================================================
*** io/file_pos.c       (revision 109064)
--- io/file_pos.c       (working copy)
*************** st_rewind (st_parameter_filepos *fpp)
*** 255,260 ****
--- 255,261 ----

           u->endfile = NO_ENDFILE;
           u->current_record = 0;
+         u->bytes_left = 0;
           test_endfile (u);
         }
         /* Update position for INQUIRE.  */

["endfile.f" (text/x-fortran)]

! { dg-do run }
! PR25550 file data corrupted after reading end of file.
! Derived from example given in PR from Dale Ranta.
! Contributed by Jerry DeLisle  <jvdelisle@gcc.gnu.org> 
      integer data
      data=-1
      open(unit=11,status='scratch',form='unformatted')
      write(11)data
      read(11,end=1000 )data
      call abort()
 1000 continue
      rewind (11)
      read(11)data
 1001 continue
      if(data.ne.-1) call abort
      end




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic