Boost C++ Libraries: Ticket #10809: Seeking breaks iostreams::restriction<std::istream> internal state https://svn.boost.org/trac10/ticket/10809 <p> As in the attached test case, calling seekg() on a restricted istream appears to break the internal state such that more characters can be extracted than expected. </p> <p> I've done some digging around, and I think this is because the restriction device does a seek relative to std::ios_base::cur, which returns -1 from the underlying implementation: Calling std::streambuf::pubseekoff() with way = ios_base::cur and which = (ios_base::in | ios_base::out) fails according to the C++ standard section 27.8.2.4. </p> <p> When fixing this, it's worth noting that calling pubseekoff() will also fail with libstdc++ if it's passed (ios_base::in | ios_base::out) when the stream buffer has only an output buffer or input buffer, but not both. </p> <p> Tested with g++-4.6.3 and g++-4.8.? on 64 bit linux Ubuntu. Behaviour is consistent with clang++-libc++, but inconsistent with MSVC. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10809 Trac 1.4.3 chris42f@… Fri, 21 Nov 2014 01:48:47 GMT attachment set https://svn.boost.org/trac10/ticket/10809 https://svn.boost.org/trac10/ticket/10809 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> Test case showing the bad behaviour </p> Ticket