Boost logo

Boost :

Subject: [boost] [mpl] clang error for narrowing from unsigned int 0xffffffff to long
From: Edward Diener (eldiener_at_[hidden])
Date: 2013-11-13 15:46:18


In the mpl bitwise.cpp test there are lines like:

MPL_ASSERT_RELATION( (bitor_<_0,_ffffffff>::value), ==, 0xffffffff );
MPL_ASSERT_RELATION( (bitor_<_1,_ffffffff>::value), ==, 0xffffffff );
MPL_ASSERT_RELATION( (bitor_<_8,_ffffffff>::value), ==, 0xffffffff );

Using clang under Windows with the VC++ RTL ( clang-cl ), clang gives an
error of:

bitwise.cpp(43,25) : error: non-type template argument evaluates to
4294967295, which cannot be narrowed to type 'long' [-Wc++11-narrowing]
MPL_ASSERT_RELATION( (bitor_<_0,_ffffffff>::value), ==, 0xffffffff );

for the bitor_<_0,_ffffffff>::value expression part since the
assert_relation template takes two 'long's as its values.

Is this an actual bug according to the C++11 standard ? I would have
thought that an unsigned int value of 0xffffffff would fit into a long
as a -1, but it sounds like the new standard is saying that since the
value of 4294967295 cannot be encompassed by a long it is an error.

if it is an error how should it be fixed in MPL ?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk