[Boost-bugs] [Boost C++ Libraries] #3969: position_to_offset() is broken for Microsoft Visual C++/Dinkumware

Subject: [Boost-bugs] [Boost C++ Libraries] #3969: position_to_offset() is broken for Microsoft Visual C++/Dinkumware
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-02 12:12:49


#3969: position_to_offset() is broken for Microsoft Visual C++/Dinkumware
--------------------------------------------------+-------------------------
 Reporter: gareth.sylvester-bradley@… | Owner: turkanis
     Type: Patches | Status: new
Milestone: Boost 1.43.0 | Component: iostreams
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: |
--------------------------------------------------+-------------------------
 I have found a bug in position_to_offset() on Microsoft Visual
 C++/Dinkumware demonstrated by the following test app –

 {{{
 #include <iostream>
 #include <boost/iostreams/positioning.hpp>

 int main( int, char*[] )
 {
   const boost::int64_t twoGB = 2 << 30;
   std::streampos pos = boost::iostreams::offset_to_position( twoGB );
   pos -= 2;
   if ( twoGB - 2 != boost::iostreams::position_to_offset( pos ) )
   {
     std::cout << "Failed!" << std::endl;
     return -1;
   }

   return 0;
 }
 }}}

 This is resolved by the following patch to
 boost/iostreams/positioning.hpp.

 {{{
 105,106c105,106
 < static_cast<stream_offset>(static_cast<std::streamoff>(pos))
 -
 <
 static_cast<stream_offset>(_FPOSOFF(streampos_to_fpos_t(pos)));
 ---
> static_cast<stream_offset>(static_cast<std::streamoff>(pos) -
>
 _FPOSOFF(streampos_to_fpos_t(pos)));
 }}}

 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3969>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC