[Bug libstdc++/52169] the ifstream readsome() method does not signal any bit on eof.

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Feb 8 10:57:00 GMT 2012


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-08 10:56:18 UTC ---
(In reply to comment #1)
> cplusplus.com is (a) not authoritative, (b) full of mistakes, and (c) otherwise
> just awful.

This, x 1000

(In reply to comment #2)
> i.e. doesn't readsome become a noop when there's nothing to read?

Yes, which makes it very useful for non-blocking reads from pipes or sockets.

The testcase is simply wrong, as you can see by checking in_avail:

    cerr << "avail: " << f.rdbuf()->in_avail() << endl;

Since in_avail() doesn't return -1, readsome should not set eofbit.

There are better ways to read a whole file anyway, e.g. ostr << f.rdbuf()



More information about the Gcc-bugs mailing list