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

Tomasz Kamiński <tkaminsk at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkaminsk at gcc dot gnu.org

--- Comment #14 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
> IMO the example program is broken and cannot be used to proof violation of 
> contract of the library. This is so, because istreambuf_iterator is an input 
> iterator and any usage of operator++ potentially invalidates copies of the 
> iterator (see FDIS, Table 107, expression r++).

I believe that this argument applies for generic code, that accept any istream
iterator. However, any particular iterator may provide a stronger guarantee
that above (I see that as minimum). The wording for operator*
(https://eel.is/c++draft/istreambuf.iterator#ops-1) seem to be clear in this
case:
> Returns: The character obtained via the streambuf member sbuf_->sgetc().

Which for me clearly state that *it on each call obtain character from
sbuf_->getc(), and if the stream is modified, the modification should be
visible. I.e. libstdc++ is one that is conforming here, and no caching is
allowed.

Reply via email to