Opened 13 years ago

Closed 12 years ago

#4022 closed Bugs (fixed)

dynamic_bitset compiler issue

Reported by: anonymous Owned by: Gennaro Prota
Milestone: Boost 1.43.0 Component: dynamic_bitset
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

dynamic_bitset does not compile with int64 on Visual Studio 9. THink culprit is code below

const size_type extra_bits = count_extra_bits();

This should be

const block_width_type extra_bits = count_extra_bits();

Change History (5)

comment:1 by Steven Watanabe, 13 years ago

Component: Nonedynamic_bitset
Owner: set to Gennaro Prota

comment:2 by anonymous, 13 years ago

Resolution: fixed
Status: newclosed

comment:3 by anonymous, 13 years ago

Resolution: fixed
Status: closedreopened

comment:4 by Steven Watanabe, 13 years ago

Of course, you have to use an unsigned type. With that the code does compile, although it emits a warning. The warning is harmless in this case, although it would be better to fix it as you suggest.

#include <boost/dynamic_bitset/dynamic_bitset.hpp>

int main() {
    boost::dynamic_bitset<unsigned long long> bitset_type;
    bitset_type.resize(10, false);
}
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=unsigned __int64
        ]
        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=unsigned __int64
        ]
        .\scratch.cpp(4) : see reference to class template instantiation 'boost::dynamic_bitset<Block>' being compiled
        with
        [
            Block=unsigned __int64
        ]

comment:5 by Steven Watanabe, 12 years ago

Resolution: fixed
Status: reopenedclosed

(In [62898]) Use the correct variable type to save the result of count_extra_bits(). Fixes #4022.

Note: See TracTickets for help on using tickets.