------- Comment #3 from burnus at gcc dot gnu dot org 2007-03-09 12:55 ------- I was checking where bytes_left is set:
open.c: u->bytes_left = 0; This is the default setting in new_unit (/* Open an unused unit. */) It is also set to 0 in file_pos.c (two places). In list_read.c's next_char it is set to current_unit->recl; And in transfer.c: - read_block - write_block (but only if stdout/stderr or default reclen, otherwise a ERROR_EOR error is generated, but this is not the error of this PR.) - us_read - us_write: This one is also not called for this PR - next_record_w: Not for unformatted The problem seems to be that bytes_left == 0 from the initial setting in new_unit as no data has been written. And as 4bytes have to be written, nbytes = 4 > bytes_left. Note: The same problem occurs if one tries to read from a file which has been written by gfortran-4.1. In this case the error condition is in: transfer.c's read_block_direct: if (dtp->u.p.current_unit->flags.has_recl) { to_read_record = *nbytes > (size_t) dtp->u.p.current_unit->bytes_left ? *nbytes : (size_t) dtp->u.p.current_unit->bytes_left; short_record = 1; } else { to_read_record = *nbytes; short_record = 0; } This check has been introduced by the same patch. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31099