https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92569
Bug ID: 92569 Summary: gfortran read with end directive does not trigger in gfortran 9.2 Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: dojo at masterleep dot com Target Milestone: --- Created attachment 47294 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47294&action=edit Zip of program and datafile The attached program attempts to read 1000 lines from the input file which has only 3 lines. The statement read (1,*,end=1)(tdat(j,k),k=1,10) is supposed to transfer control to statement label 1 when the end of file condition is reached, but instead, a runtime error occurs: Fortran runtime error: Read past ENDFILE record This program worked correctly with gfortran 6 and earlier. If the statement is changed to include an err=1 directive as well, the program works. But both end=1 and err=1 must appear. Either alone will not detect the end of file. From my read of the standard, that should not be necessary. This program is a small part of a large and ancient program with many similar statements. Program: real*8 tdat(1000,10) OPEN (UNIT=1,FILE='resultav4.dat',STATUS='OLD',IOSTAT=MM) IF (MM.NE.0) WRITE (*,400) MM 400 FORMAT (' An error occured (',I4,') while opening input file') do 2, j = 1,1000 read (1,*,end=1)(tdat(j,k),k=1,10) c The following will work correctly: c read (1,*,end=1,err=1)(tdat(j,k),k=1,10) 2 continue 1 np = j-1 write(*,*)' # data records =',np close (1) end Datafile: 0.00000000 2.18666673 -2.09299994 0.697333336 -5.29666662 0.453666657 -5.46999979 -12.0633326 -6.87000036 -14.1999998 -10.4799995 -14.6400003 -13.8499994 3.55556011E-02 2.28749990 -2.86975002 0.853000045 -7.17249966 -0.869750023 -5.42749977 -10.6499996 -6.34250021 -13.4749994 -10.7349997 -16.9300003 -15.1625004 7.11110979E-02 2.36599994 -2.88180017 -0.337599933 -7.21799994 -1.81980002 -5.88199997 -10.8399992 -6.14000034 -12.0999994 -12.5879993 -15.7040005 -15.4700012