[http://gcc.gnu.org/ml/fortran/2006-11/msg00708.html]
The following file gives an end-of-file error when attempting to read a
too-short record from an unformatted file, and if END= is specified on the READ
line, it will be (erroneously) followed:
program test3
IMPLICIT NONE
INTEGER :: I,J,K
I=1
J=2
K=3
OPEN(1,FILE='test3.dat',STATUS='NEW',FORM='UNFORMATTED',
& ACTION='WRITE')
WRITE(1) I
WRITE(1) I, J, K
WRITE(1) I, J, K
CLOSE(1)
OPEN(1,FILE='test3.dat',STATUS='OLD',FORM='UNFORMATTED',
& ACTION='READ')
print*, "before read err=10"
READ(1,ERR=10) I,J,K
print*, "after read err=10"
10 CONTINUE
print*, "after 10 continue "
print*," I = ", I
print*," J = ", J
print*," K = ", K
END PROGRAM
>gfortran -g test6.f
>rm test3.dat
>./a.out
before read err=10
At line 18 of file test6.f
Fortran runtime error: End of file
This is a regression against g77.
Also, PR 29627 looks like it might be related.
--
Summary: [regression] Too-short record on unformatted read
treated as EOF.
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: brooks at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30010