Boost logo

Boost :

Subject: [boost] [iostreams][patch] position_to_offset() is broken for Microsoft Visual C++/Dinkumware
From: Sylvester-Bradley, Gareth (Gareth.Sylvester-Bradley_at_[hidden])
Date: 2010-03-02 07:20:10


The recent work on Boost.Iostreams by Richard Smith and Daniel James has
really improved this library. Thanks guys; this kind of maintenance is
really appreciated.

 

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 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.

 

I believe 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)));
 
Raised on Trac: https://svn.boost.org/trac/boost/ticket/3969
 
Best regards,
Gareth
 
************************************************************************
The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s).  Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender.  The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies.  Sony email is for business use only.
This email and any response may be monitored by Sony to be in compliance with Sony's global policies and standards

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk