Boost C++ Libraries: Ticket #586: iostreams // file_descriptor::seek BUG on files > 4 GB https://svn.boost.org/trac10/ticket/586 <pre class="wiki"> Boost 1.33.1 iostreams library file_descriptor::seek() method file_descriptor.cpp, line 198 Win32, Visual C++ 2005 The method seek() can return a wrong value of a newly set offset when the offset is further than 4 GB. //--------------- return offset_to_position((lDistanceToMoveHigh &lt;&lt; 32) + dwResultLow); //--------------- The code above has a bug. On 32-bit systems the expression (lDistanceToMoveHigh &lt;&lt; 32) equals to lDistanceToMoveHigh. The correct code should first cast the lDistanceToMoveHigh variable to 64-bit and then shift it. //--------------- return (static_cast&lt;boost::intmax_t&gt; lDistanceToMoveHigh) &lt;&lt; 32) + dwResultLow; //--------------- Sergey Kolodkin </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/586 Trac 1.4.3 gmsb Wed, 31 Jan 2007 16:27:00 GMT <link>https://svn.boost.org/trac10/ticket/586#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/586#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=271167 Originator: NO There's also a bug 3 lines earlier. Windows GetLastError() shouldn't be checked unless dwResultLow is INVALID_SET_FILE_POINTER. Replace: 195 if (::GetLastError() != NO_ERROR) { 196 throw detail::bad_seek(); 197 } else { 198 return offset_to_position((lDistanceToMoveHigh &lt;&lt; 32) + dwResultLow); 199 } 200 } With: 195 if (INVALID_SET_FILE_POINTER == dwResultLow &amp;&amp; ::GetLastError() != NO_ERROR) { 196 throw detail::bad_seek(); 197 } else { 198 return offset_to_position((static_cast&lt;stream_offset&gt;(lDistanceToMoveHigh) &lt;&lt; 32) + dwResultLow); 199 } 200 } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Daryle Walker</dc:creator> <pubDate>Fri, 03 Aug 2007 12:03:40 GMT</pubDate> <title>component changed; severity set https://svn.boost.org/trac10/ticket/586#comment:2 https://svn.boost.org/trac10/ticket/586#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">iostreams</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket Frank Birbacher Fri, 24 Aug 2007 01:41:08 GMT <link>https://svn.boost.org/trac10/ticket/586#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/586#comment:3</guid> <description> <p> Bug noted and addressed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/38880" title="Changed types involved in file size calculation. Adresses #586">[38880]</a>. Still needs approval of maintainer. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jonathan Turkanis</dc:creator> <pubDate>Sun, 30 Dec 2007 02:18:57 GMT</pubDate> <title>status, resolution changed https://svn.boost.org/trac10/ticket/586#comment:4 https://svn.boost.org/trac10/ticket/586#comment:4 <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-old">None</span> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Both problems are fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/42266" title="ported changes from branches/iostreams_dev revisions 42144-42265">[42266]</a> </p> Ticket