Opened 7 years ago

Last modified 5 years ago

#11390 new Bugs

Wrong type in dynamic_bitset::reference constructor

Reported by: stefan.atev@… Owned by: jsiek
Milestone: To Be Determined Component: dynamic_bitset
Version: Boost 1.58.0 Severity: Problem
Keywords: Cc:

Description

When compiling with visual studio 2013, the following warning is issued (and since we treat these as errors, fails the compilation):

boost/dynamic_bitset/dynamic_bitset.hpp(298): warning C4267: 'argument' : conversion from 'size_t' to 'unsigned long', possible loss of data

The culprit is the reference constructor:

reference(block_type & b, block_type pos)

which should be:

reference(block_type & b, block_width_type pos)

used in the non-const accessor:

reference operator[](size_type pos) {

return reference(m_bits[block_index(pos)], bit_index(pos));

}

bit_index() is defined as returning block_width_type, not block_type (which may be narrower).

The const accessor works as expected and is a possible workaround when read-only access is required from a non-const bitset.

Change History (2)

comment:1 by anonymous, 5 years ago

Does anyone maintain this library?

comment:2 by stefan.atev@…, 5 years ago

Apparently it is not maintained, I reported this against 1.58, and it's still in 1.62; I just trained myself to use .set() and .test()

Note: See TracTickets for help on using tickets.