From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3384 invoked by alias); 12 Jun 2011 15:16:29 -0000 Received: (qmail 3375 invoked by uid 22791); 12 Jun 2011 15:16:28 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 12 Jun 2011 15:16:15 +0000 From: "pogonyshev at gmx dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/49384] New: istringstream::tellg at the end of string gives a wrong result X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pogonyshev at gmx dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sun, 12 Jun 2011 15:16:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01045.txt.bz2 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.