Opened 9 years ago

Closed 8 years ago

#9725 closed Bugs (fixed)

dynamic_bitset.hpp: implicit conversion changes signedness

Reported by: Thomas Klausner <tk@…> Owned by: acharles
Milestone: Boost 1.56.0 Component: dynamic_bitset
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

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.

Attachments (1)

db.patch (996 bytes ) - added by Thomas Klausner <tk@…> 9 years ago.
Patch adding casts that fixes the warnings.

Download all attachments as: .zip

Change History (7)

by Thomas Klausner <tk@…>, 9 years ago

Attachment: db.patch added

Patch adding casts that fixes the warnings.

comment:1 by acharles, 8 years ago

Milestone: To Be DeterminedBoost 1.56.0
Owner: changed from jsiek to acharles

I'll take a look at this.

comment:2 by acharles, 8 years ago

Additionally: Would you mind submitting this as a pull request on the repository with the ticket in the commit message? If you aren't very familiar with git/github, then I can do this.

comment:3 by Thomas Klausner <tk@…>, 8 years ago

I've just created a pull request. Thanks for looking at this!

comment:4 by acharles, 8 years ago

I don't see the pull request, could you paste a link?

It should show up here: https://github.com/boostorg/dynamic_bitset/pulls

comment:5 by acharles, 8 years ago

Nevermind, someone else merged it.

comment:6 by acharles, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.