https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92569
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|fortran |libfortran
--- Comment #5 from anlauf at gcc dot gnu.org ---
Running the failing testcase under the debugger, it appears that the
end-of-file condition is not properly dealt with in the library:
transfer.c:
2542
2543 data = GFC_DESCRIPTOR_DATA (desc);
2544
2545 while (data)
2546 {
2547 dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize);
2548 data += stride0 * tsize;
2549 count[0] += tsize;
2550 n = 0;
2551 while (count[n] == extent[n])
(gdb) p dtp->u.p.current_unit->endfile
one gets after the last valid read
$2 = NO_ENDFILE
and after the first attempt pase EOF:
(gdb) p dtp->u.p.current_unit->endfile
$5 = AFTER_ENDFILE
and after the next attempt:
At line 8 of file res.f (unit = 1, file = 'resultav4.dat')
Fortran runtime error: Read past ENDFILE record
So one needs to check and properly catch the ENDFILE condition.
Who knows the right way to deal with such conditions?