|
Boost : |
Subject: [boost] Dynamic bitset library - compilation problem on windows (boost 1_37_0onwards)
From: Aniket Bhat (anbhat_at_[hidden])
Date: 2009-05-13 11:43:48
I am seeing problems with msvc when compiling a simple code snippet that
instantiates a dynamic_bitset with a uint64_t. The problem occurs when
instantiating a template specialization for the resize function for
uint64_t. There was a change made to the block_width_type typedef from an
int in 1_36_0 to block_type in 1_37_0. This change seems to have broken
support for uint64_t data-types on 32-bit windows systems or any other types
which are bigger than size_t on a given platform.
Code snippet:
#include <boost/dynamic_bitset.hpp>
#include <iostream>
#if defined (__GNUC__)
#if !defined (SUNOS_OS)
typedef unsigned long long uint64_t;
#endif
#else
typedef unsigned __int64 uint64_t;
#endif
typedef uint64_t myType;
boost::dynamic_bitset<myType>::size_type
foo()
{
unsigned int blockHandles(10);
return (boost::dynamic_bitset<myType>::size_type
)(blockHandles*sizeof(myType)*8);
}
int main(int argc,char**argv)
{
boost::dynamic_bitset<myType>::size_type t = foo();
boost::dynamic_bitset<myType> m_myBitSet;
m_myBitSet.resize(12,false);
}
Compilation error:
Compiling...
TestBitSet.cpp
c:\p3_dev_boost\common\lib\boost_1_39_0\boost\dynamic_bitset\dynamic_bitset.hpp(673)
: error C2220: warning treated as error - no 'object' file generated
c:\p3_dev_boost\common\lib\boost_1_39_0\boost\dynamic_bitset\dynamic_bitset.hpp(649)
: while compiling class template member function 'void
boost::dynamic_bitset<Block>::resize(boost::dynamic_bitset<Block>::size_type,bool)'
with
[
Block=myType
]
c:\documents and settings\abhat\my
documents\aniket\projects\dynamic_bitset\testbitset\testbitset.cpp(17) : see
reference to class template instantiation 'boost::dynamic_bitset<Block>'
being compiled
with
[
Block=myType
]
c:\p3_dev_boost\common\lib\boost_1_39_0\boost\dynamic_bitset\dynamic_bitset.hpp(673)
: warning C4244: 'initializing' : conversion from 'unsigned __int64' to
'const boost::dynamic_bitset<Block>::size_type', possible loss of data
with
[
Block=myType
]
The resize function (dynamic_bitset.hpp:673) calls count_extra_bits() which
returns a size_type instead of block_width_type resulting in possible loss
of data. At all other places this function is called within the header, it
returns a block_width_type. I am not sure if it has to return a size_type in
this particular case for a specific reason?
Thanks,
Aniket.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk