https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107031
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Sun, Sep 25, 2022 at 08:56:22PM +0000, kargl at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107031 > > --- Comment #4 from kargl at gcc dot gnu.org --- > (In reply to anlauf from comment #3) > > (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. > > If the current record contain '6', the next record contains '7'. > 'next' does not mean 'current' in the English language. It means > something that 'follows'. > Further confusion, maybe? 12.3.4 File position 12.3.4.1 General ... Let n be the number of records in the file. ... If 1 <= i < n and a file is positioned within the ith record or between the ith and (i + 1)th record, the (i + 1)th record is the next record.