https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107031
--- Comment #3 from anlauf at gcc dot gnu.org --- (In reply to kargl from comment #2) > gfortran's current behavior is correct. > > > 12.3.4.4 File position after data transfer > > In all other cases, the file is positioned after the record just > read or written and that record becomes the preceding record. > > 12.8.3 ENDFILE statement > > Execution of an ENDFILE statement for a file connected for sequential > access writes an endfile record as the next record of the file. > > After reading '5', the file is position at the record that contains '6'. > So, ENDIFLE writes the endfile record after the record with '6'. Hmm, interpretation of text? I read "as the next record", not "after the next record". gfortran differs here from Intel, NAG, Nvidia, AMD Flang, Crayftn.