public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marc.glisse at normalesup dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/46906] New: istreambuf_iterator is late?
Date: Sun, 12 Dec 2010 15:26:00 -0000	[thread overview]
Message-ID: <bug-46906-4@http.gcc.gnu.org/bugzilla/> (raw)

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

           Summary: istreambuf_iterator is late?
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marc.glisse@normalesup.org


The following program prints:
11
12
32

With some other libraries I get 11 22 33 (but libstdc++ is not the only one
that outputs 11 12 32).

As far as I understand the standard, operator++ and operator* should just call
sbumpc and sgetc on the underlying streambuf, which happens to be the same for
the two iterators. It looks like the iterator caches the result somehow. Am I
missing some provision for this in the standard?


#include <ios>
#include <istream>
#include <sstream>
#include <iostream>

using namespace std;
int main(){
    istringstream s("1234");
    istreambuf_iterator<char> i1(s);
    istreambuf_iterator<char> i2(i1);
    std::cerr << *i1 << *i2 << '\n';
    ++i2;
    std::cerr << *i1 << *i2 << '\n';
    ++i1;
    std::cerr << *i1 << *i2 << '\n';
}


             reply	other threads:[~2010-12-12 15:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12 15:26 marc.glisse at normalesup dot org [this message]
2010-12-12 17:38 ` [Bug libstdc++/46906] " paolo.carlini at oracle dot com
2010-12-12 18:01 ` marc.glisse at normalesup dot org
2010-12-12 18:28 ` paolo.carlini at oracle dot com
2011-09-05  9:49 ` daniel.kruegler at googlemail dot com
2011-09-05 10:00 ` marc.glisse at normalesup dot org
2011-09-05 11:11 ` daniel.kruegler at googlemail dot com
2011-09-05 12:39 ` marc.glisse at normalesup dot org
2011-09-05 12:57 ` daniel.kruegler at googlemail dot com
2011-09-05 14:02 ` marc.glisse at normalesup dot org
2011-09-05 14:17 ` daniel.kruegler at googlemail dot com
2011-09-05 15:06 ` marc.glisse at normalesup dot org
2012-08-22 20:00 ` glisse at gcc dot gnu.org
2023-05-17 14:46 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-46906-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).