C++: Reading past the end of a file when using eof()
Alexander Klein
Alexander.Klein@math.uni-giessen.de
Wed Oct 24 13:32:00 GMT 2001
Hello,
Today, I stumbled across a problem using eof() for a file stream.
According to Stroustrup's book, a state of eof() indicates,
that the last read was valid and the next one will go past the end
of the file.
However, what happens on my machine (NetBSD/m68k) is, that _after_ reading
past the end of the file both, eof() and fail() become set at the same
time, which is - as far as can tell from Stroustrup's book - not the
intended behaviour of eof().
Attached is the .ii-File of the compiled program.
I use the following gcc:
Reading specs from /usr/local/lib/gcc-lib/m68k-apple-netbsd1.5.1/2.95.3/specs
gcc version 2.95.3 20010315 (release)
which is started with:
/usr/local/bin/g++ -I/home/Alex/include -L/home/Alex/lib -m68040
Best regards
Alex Klein
More information about the Gcc-bugs
mailing list