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: unassig...@gcc.gnu.org
        ReportedBy: pogonys...@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.

Reply via email to