Boost C++ Libraries: Ticket #8572: iosteams indirect_streambuf::init_put_area should seek if data has been read from the get buffer https://svn.boost.org/trac10/ticket/8572 <p> The following code with std::fstream prints 0x1801 but with boost::iostream prints 0x2000: </p> <pre class="wiki"> boost::iostreams::stream&lt; boost::iostreams::file &gt; ios( boost::iostreams::file( "test.dat", std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc ), 0x800 ); //std::fstream ios( "test.dat", std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc ); char buffer[ 0x2000 ]; ios.write( buffer, 0x2000 ); ios.seekg( -0x1000, std::ios_base::cur ); ios.get(); ios.write( buffer, 0x800 ); std::cout &lt;&lt; std::hex &lt;&lt; ios.tellp() &lt;&lt; std::endl; std::cout &lt;&lt; std::hex &lt;&lt; ios.tellg() &lt;&lt; std::endl; </pre><p> I believe the problem lies in indirect_streambuf::init_put_area. The current implementation is: </p> <pre class="wiki"> if (shared_buffer() &amp;&amp; gptr() != 0) setg(0, 0, 0); if (output_buffered()) setp(out().begin(), out().end()); else setp(0, 0); </pre><p> I think it should be: </p> <pre class="wiki"> if (shared_buffer() &amp;&amp; gptr() != 0) { obj().seek(gptr()-egptr(), BOOST_IOS::cur, BOOST_IOS::in, next_); setg(0, 0, 0); } if (output_buffered()) setp(out().begin(), out().end()); else setp(0, 0); </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8572 Trac 1.4.3