[Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 28 09:23:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-12-28 09:23:07 UTC ---
A similar issue exists for complex variables. Here, the value is correctly
read, but one still gets an EOF error.
Also with
character :: var
one runs into the problem. For
write(99) "1", new_line("")
write(99) "2", new_line("")
write(99) "3"
the last line is not read and stat == -1.
Test case for COMPLEX:
implicit none
integer :: stat
complex :: var
open(99, file="test.dat", access="stream", form="unformatted", status="new")
write(99) "(1,2)", new_line("")
write(99) "(2,3)", new_line("")
write(99) "(4,5)"
close(99)
open(99, file="test.dat")
read (99,*, iostat=stat) var
print *, stat, var
if (stat /= 0 .or. var /= cmplx(1,2)) call abort()
read (99,*, iostat=stat) var
print *, stat, var
if (stat /= 0 .or. var /= cmplx(2,3)) call abort()
read (99,*, iostat=stat) var ! << FAILS: stat /= 0, value is okay
print *, stat, var
if (stat /= 0 .or. var /= cmplx(4,5)) call abort()
close(99, status="delete")
end
More information about the Gcc-bugs
mailing list