Opened 8 years ago

#10818 new Bugs

A C4267 "possible loss of data" warning when compiling on VS2013 x64 with /W4

Reported by: kaa123@… Owned by: jsiek
Milestone: To Be Determined Component: dynamic_bitset
Version: Boost 1.56.0 Severity: Cosmetic
Keywords: Cc:

Description

Example:

boost::dynamic_bitset<> flags;

...

bool b = flags[56];

Warning when calling the reference class constructor from the [] operator.

Compiler -- VS2013, Platform -- x64, Debug mode, Warning level -- /W4.

Fix: I found if you changed the pos parameter of the reference class constructor to size_type, the warning went away.

From:

reference(block_type & b, block_type pos)

To:

reference(block_type & b, size_type pos)

Location Line 88 of dynamic_bitset.hpp

Actual error message:

4>C:\Boost\1_56_0-VS_2013-x64\include\boost-1_56\boost/dynamic_bitset/dynamic_bitset.hpp(296): warning C4267: 'argument' : conversion from 'size_t' to 'unsigned long', possible loss of data 4> C:\Boost\1_56_0-VS_2013-x64\include\boost-1_56\boost/dynamic_bitset/dynamic_bitset.hpp(295) : while compiling class template member function 'boost::dynamic_bitset<unsigned long,std::allocator<Block>>::reference boost::dynamic_bitset<Block,std::allocator<Block>>::operator [](boost::dynamic_bitset<Block,std::allocator<Block>>::size_type)'

reference(block_type & b, size_type pos)

Change History (0)

Note: See TracTickets for help on using tickets.