error when copying blocks into a dynamic_bitset

Hi, I'm trying to initialize a dynamic_bitset<unsigned char> from a vector of blocks. Here's the code: #include <cstdlib> #include <vector> #include <boost/dynamic_bitset.hpp> typedef boost::dynamic_bitset<unsigned char> BitSet; typedef std::vector<BitSet::block_type> Block; int main(int argc, char* argv[]) { int nbits = atoi( argv[1] ); BitSet bits( nbits ); Block buffer; buffer.resize( bits.num_blocks(), 0xff ); boost::from_block_range(buffer.begin(),buffer.end(), bits ); return 0; } If the bitset size isn't a multiple of sizeof(unsigned char) (here 8) , ~dynamic_bitset() throws an exception. For example: % ./a.out 1 a.out: boost-1.60.0/include/boost/dynamic_bitset/dynamic_bitset.hpp:633: boost::dynamic_bitset<Block, Allocator>::~dynamic_bitset() [with Block = unsigned char; Allocator = std::allocator<unsigned char>]: Assertion `m_check_invariants()' failed. Aborted % ./a.out 8 % ./a.out 15 a.out: boost-1.60.0/boost/dynamic_bitset/dynamic_bitset.hpp:633: boost::dynamic_bitset<Block, Allocator>::~dynamic_bitset() [with Block = unsigned char; Allocator = std::allocator<unsigned char>]: Assertion `m_check_invariants()' failed. Aborted % ./a.out 16 % I see this with 1.59 & 1.60 using either g++ 4.7.2 or Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) I believe that I'm following the rules for the buffer type and size. Is there something I'm missing? Thanks! Diab
participants (1)
-
Diab Jerius