Boost C++ Libraries: Ticket #3969: position_to_offset() is broken for Microsoft Visual C++/Dinkumware https://svn.boost.org/trac10/ticket/3969 <p> I have found a bug in position_to_offset() on Microsoft Visual C++/Dinkumware demonstrated by the following test app – </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/iostreams/positioning.hpp&gt; int main( int, char*[] ) { const boost::int64_t twoGB = 2 &lt;&lt; 30; std::streampos pos = boost::iostreams::offset_to_position( twoGB ); pos -= 2; if ( twoGB - 2 != boost::iostreams::position_to_offset( pos ) ) { std::cout &lt;&lt; "Failed!" &lt;&lt; std::endl; return -1; } return 0; } </pre><p> This is resolved by the following patch to boost/iostreams/positioning.hpp. </p> <pre class="wiki">105,106c105,106 &lt; static_cast&lt;stream_offset&gt;(static_cast&lt;std::streamoff&gt;(pos)) - &lt; static_cast&lt;stream_offset&gt;(_FPOSOFF(streampos_to_fpos_t(pos))); --- &gt; static_cast&lt;stream_offset&gt;(static_cast&lt;std::streamoff&gt;(pos) - &gt; _FPOSOFF(streampos_to_fpos_t(pos))); </pre><p> This has the potential to affect many parts of Boost.Iostreams but in particular it means the "small seeks optimization" in indirect_streambuf.hpp is broken. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3969 Trac 1.4.3 Daniel James Fri, 12 Mar 2010 19:34:33 GMT owner, status changed https://svn.boost.org/trac10/ticket/3969#comment:1 https://svn.boost.org/trac10/ticket/3969#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Jonathan Turkanis</span> to <span class="trac-author">Daniel James</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Daniel James Sun, 14 Mar 2010 18:00:47 GMT <link>https://svn.boost.org/trac10/ticket/3969#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3969#comment:2</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/60581" title="In `position_to_offset`, only cast to `stream_offset` after ...">[60581]</a>) In <code>position_to_offset</code>, only cast to <code>stream_offset</code> after calculating <code>_Myoff</code>. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3969" title="#3969: Patches: position_to_offset() is broken for Microsoft Visual C++/Dinkumware (closed: fixed)">#3969</a>. </p> <p> Thanks to Garth Sylvester-Bradley. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Wed, 17 Mar 2010 00:23:34 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3969#comment:3 https://svn.boost.org/trac10/ticket/3969#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/60666" title="Merge iostreams. - Fix write_device_impl&lt;ostream_tag&gt;. Fixes #3839 ...">[60666]</a>) Merge iostreams. </p> <ul><li>Fix write_device_impl&lt;ostream_tag&gt;. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3839" title="#3839: Bugs: [iostreams]write.hpp:write_device_impl&lt;ostream_tag&gt; tries access ... (closed: fixed)">#3839</a> </li><li>Fix error checks after calling <a class="missing wiki">SetFilePointer</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3953" title="#3953: Bugs: [boost][iostreams] mapped_file bug on Win32? (closed: fixed)">#3953</a> </li><li>Gzip filter shouldn't require its source to be peekable. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3723" title="#3723: Bugs: gzip_docompressor error - basic_array_source no putback member (closed: fixed)">#3723</a>. </li><li>In <code>position_to_offset</code>, only cast to <code>stream_offset</code> after calculating <code>_Myoff</code>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3969" title="#3969: Patches: position_to_offset() is broken for Microsoft Visual C++/Dinkumware (closed: fixed)">#3969</a>. </li><li>ptrdiff_t is in std. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2505" title="#2505: Bugs: iostreams/test/grep_test.cpp assumes that ptrdiff_t is in the global ... (closed: fixed)">#2505</a>. </li></ul> Ticket