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



             Bug #: 55818

           Summary: Reading a REAL from a file which doesn't end in a new

                    line fails

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: fortran

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: bur...@gcc.gnu.org

                CC: jvdeli...@gcc.gnu.org





Reported by Elzbieta Burnett at

https://groups.google.com/d/msg/comp.lang.fortran/_HBMfv1lR3w/7b28oDQH2sUJ



The following program works for INTEGER but not for REAL. See also c.l.f for a

similar example.



The file looks like "1\n2\n3" without a "\n" after the 3. That fails for

list-directed read.





implicit none

integer :: stat

!integer :: var ! << works

real    :: var ! << fails



open(99, file="test.dat", access="stream", form="unformatted", status="new")

write(99) "1", new_line("")

write(99) "2", new_line("")

write(99) "3"

close(99)



open(99, file="test.dat")

read (99,*, iostat=stat) var

if (stat /= 0 .or. var /= 1) call abort()

read (99,*, iostat=stat) var

if (stat /= 0 .or. var /= 2) call abort()

read (99,*, iostat=stat) var              ! << FAILS: stat /= 0

if (stat /= 0 .or. var /= 3) call abort() ! << aborts here

close(99, status="delete")

end

Reply via email to