public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result
@ 2011-06-12 15:16 pogonyshev at gmx dot net
  2011-06-12 18:55 ` [Bug libstdc++/49384] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pogonyshev at gmx dot net @ 2011-06-12 15:16 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/49384] istringstream::tellg at the end of string gives a wrong result
  2011-06-12 15:16 [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result pogonyshev at gmx dot net
@ 2011-06-12 18:55 ` paolo.carlini at oracle dot com
  2011-06-13 20:10 ` pogonyshev at gmx dot net
  2011-06-13 21:12 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-06-12 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-06-12 18:54:52 UTC ---
The new behavior is intended, see this exchange for further details:

  http://gcc.gnu.org/ml/libstdc++/2011-04/msg00026.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/49384] istringstream::tellg at the end of string gives a wrong result
  2011-06-12 15:16 [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result pogonyshev at gmx dot net
  2011-06-12 18:55 ` [Bug libstdc++/49384] " paolo.carlini at oracle dot com
@ 2011-06-13 20:10 ` pogonyshev at gmx dot net
  2011-06-13 21:12 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pogonyshev at gmx dot net @ 2011-06-13 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paul Pogonyshev <pogonyshev at gmx dot net> 2011-06-13 20:09:49 UTC ---
So, changing in a way incompatible to what the standard says is intended?  Or
am I (and pre-4.6 libstdc++) misreading the standard?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/49384] istringstream::tellg at the end of string gives a wrong result
  2011-06-12 15:16 [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result pogonyshev at gmx dot net
  2011-06-12 18:55 ` [Bug libstdc++/49384] " paolo.carlini at oracle dot com
  2011-06-13 20:10 ` pogonyshev at gmx dot net
@ 2011-06-13 21:12 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-06-13 21:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-06-13 21:11:57 UTC ---
The published C++ Standard has DEFECTS, as any other Standard. With time,
defects are analyzed, fixes found (which then become part of the Standard
actually in force) and then implemented by the implementors, like GCC.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-13 21:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-12 15:16 [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result pogonyshev at gmx dot net
2011-06-12 18:55 ` [Bug libstdc++/49384] " paolo.carlini at oracle dot com
2011-06-13 20:10 ` pogonyshev at gmx dot net
2011-06-13 21:12 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).