[Boost-bugs] [Boost C++ Libraries] #9725: dynamic_bitset.hpp: implicit conversion changes signedness

Subject: [Boost-bugs] [Boost C++ Libraries] #9725: dynamic_bitset.hpp: implicit conversion changes signedness
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-28 10:42:33


#9725: dynamic_bitset.hpp: implicit conversion changes signedness
------------------------------------+----------------------------
 Reporter: Thomas Klausner <tk@…> | Owner: jsiek
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: dynamic_bitset
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------------+----------------------------
 When compiling code against boost-1.55.0 (on NetBSD-6.99.33/amd64 with
 clang-3.5 trunk 201163, but reportedly also on OS X with clang) I get
 signedness warnings when using dynamic_bitset.hpp:

 In file included from /usr/pkg/include/boost/dynamic_bitset.hpp:15:
 /usr/pkg/include/boost/dynamic_bitset/dynamic_bitset.hpp:1697:14: warning:
 implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-
 conversion]
            + static_cast<int>( num_bits % bits_per_block != 0 );
            ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/pkg/include/boost/dynamic_bitset/dynamic_bitset.hpp:388:23: note: in
 instantiation of member function 'boost::dynamic_bitset<unsigned long,
 std::__1::allocator<unsigned long> >::calc_num_blocks' requested h\
 ere
         m_bits.resize(calc_num_blocks(num_bits));
                       ^
 /usr/pkg/include/boost/dynamic_bitset/dynamic_bitset.hpp:600:5: note: in
 instantiation of member function 'boost::dynamic_bitset<unsigned long,
 std::__1::allocator<unsigned long> >::init_from_unsigned_long' requ\
 ested here
     init_from_unsigned_long(num_bits, value);
     ^
 ../../../path/to/Table.cc:186:28: note: in instantiation of member
 function 'boost::dynamic_bitset<unsigned long,
 std::__1::allocator<unsigned long> >::dynamic_bitset' requested here
     Matches *matches = new Matches(get_num_rows());
                            ^


 In file included from /usr/pkg/include/boost/dynamic_bitset.hpp:15:
 /usr/pkg/include/boost/dynamic_bitset/dynamic_bitset.hpp:1233:33: warning:
 implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-
 conversion]
     return i * bits_per_block + boost::lowest_bit(m_bits[i]);
                               ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/pkg/include/boost/dynamic_bitset/dynamic_bitset.hpp:1242:12: note: in
 instantiation of member function 'boost::dynamic_bitset<unsigned long,
 std::__1::allocator<unsigned long> >::m_do_find_from' requested h\
 ere
     return m_do_find_from(0);
            ^
 ../../../path/to/some.xs:145:30: note: in instantiation of member function
 'boost::dynamic_bitset<unsigned long, std::__1::allocator<unsigned long>
>::find_first' requested here
     for (size_t j = matches->find_first(); j != nfotex_gtl::Matches::npos;
 j = matches->find_next(j)) {
                              ^



 In file included from /usr/pkg/include/boost/dynamic_bitset.hpp:15:
 /usr/pkg/include/boost/dynamic_bitset/dynamic_bitset.hpp:1264:32: warning:
 implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-
 conversion]
         blk * bits_per_block + lowest_bit(fore)
                              ~ ^~~~~~~~~~~~~~~~
 ../../../path/to/some.xs:145:89: note: in instantiation of member function
 'boost::dynamic_bitset<unsigned long, std::__1::allocator<unsigned long>
>::find_next' requested here
     for (size_t j = matches->find_first(); j != nfotex_gtl::Matches::npos;
 j = matches->find_next(j)) {
 ^
 I've checked the git repository, the corresponding lines are unchanged
 since then.
 Attached is a patch adding casts that fixes this.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9725>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC