After writing to or reading from an unformatted file an attempt to read from
standard input causes a crash with "Fortran runtime error: End of file".

I have gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) on Fedora Core 5. My system
is x86_64 but I have seen the same problem on i686.

Sample Code

----------------------------------------------------------
PROGRAM test
INTEGER :: n, ii(10)

print *, '1: enter a number.'
read *, n
ii(:) = n
OPEN(unit=5,file='binary.dat',form="unformatted")
WRITE(5) ii(:)
CLOSE(5)

print *, '2: enter a number.'
read *, n
OPEN(unit=5,file='binary.dat',form="unformatted")
READ(5) ii(:)
CLOSE(5)

print *, '3: enter a number.'
read *, n

END PROGRAM test
---------------------------------------------------------

Either the second or the third read statement (if the second is commented out)
will cause the "Fortran runtime error: End of file" crash.


-- 
           Summary: crash when reading from standard input after
                    writing/reading unformatted file
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mark dot baertschy at gmail dot com
  GCC host triplet: 4.1.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29259

Reply via email to