public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/46906] New: istreambuf_iterator is late?
@ 2010-12-12 15:26 marc.glisse at normalesup dot org
  2010-12-12 17:38 ` [Bug libstdc++/46906] " paolo.carlini at oracle dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: marc.glisse at normalesup dot org @ 2010-12-12 15:26 UTC (permalink / raw)
  To: gcc-bugs

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';
}


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

end of thread, other threads:[~2023-05-17 14:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-12 15:26 [Bug libstdc++/46906] New: istreambuf_iterator is late? marc.glisse at normalesup dot org
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

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).