[patch,libgfortran] PR28339 gfortran misses a record from a format statement

Jerry DeLisle jvdelisle@verizon.net
Thu Jul 20 04:02:00 GMT 2006


:ADDPATCH fortran:

This problem actually has nothing to do with format statements.  In fact, I 
could reproduce this with:

   character*8   rec(3)
   write(rec,'(a)') "12345678",/,"record1",/,"records3"

In next_record_w we (I) failed to advance to the next record when the entire 
first record was filled.  This caused the second record to be written twice, 
making it look like "record2" was missing.

To correct this it is necessary to complete next_record_w but not generate an 
ERROR_END until later.  if an attempt is made to write again to the internal 
unit (character array) after the last record is reached, an error is generated.

I used the existing endfile enumerator to accomplish this. I verified that we 
still get an ERROR_END on a scaler string.

Bootstrapped and Regression tested.  NIST tested.

OK for 4.2 trunk?  New test case attached.

Regards,

Jerry


2006-07-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/28339
	* io/transfer.c (next_record_w): Use next_array_record result to set
	END_FILE. (write_block): Test for END_FILE before the next write occurs.
	* io/init.c (get_internal_unit): Initialize iunit->endfile for internal
	unit.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr28339.diff
Type: text/x-patch
Size: 2336 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060720/acb12a50/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arrayio_8.f90
Type: text/x-fortran
Size: 533 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060720/acb12a50/attachment-0001.bin>


More information about the Fortran mailing list