https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92569
--- Comment #6 from anlauf at gcc dot gnu.org --- Something like the following fixes the testcase, but leads to regressions elsewhere in the testsuite (e.g. direct_io_{9,10}.f): Index: libgfortran/io/transfer.c =================================================================== --- libgfortran/io/transfer.c (Revision 278593) +++ libgfortran/io/transfer.c (Arbeitskopie) @@ -2544,6 +2544,8 @@ while (data) { + if (unlikely (dtp->u.p.current_unit->endfile == AFTER_ENDFILE)) + return; dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize); data += stride0 * tsize; count[0] += tsize;