This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result
- From: "pogonyshev at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 12 Jun 2011 15:16:15 +0000
- Subject: [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49384
Summary: istringstream::tellg at the end of string gives a
wrong result
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pogonyshev@gmx.net
According to the specification:
Returns: After constructing a sentry object, if fail() != false, returns
pos_type(-1) to indicate failure. Otherwise, returns rdbuf()->pubseekoff(0,
cur, in).
Tested with geordi:
{ istringstream x ("lol"); string y; x >> y; cout << y, x.fail (); cout,
x.tellg (); cout, x.rdbuf ()->pubseekoff (0, ios::cur, ios::in); }
Output:
lol, false, -1, 3
Note that fail() returns 'false', yet tellg() gives -1. Also, I tested the
standard-prescribed return value above: it is 3 as expected, suggesting that
tellg() tests eof() rather than fail() to decide if return -1 or not.
This used to work as standardized before (I believe with 4.6.0 too, though not
sure). I noticed after my program stopped working correctly without any
changes, just compiler upgrade.