Opened 13 years ago
Last modified 4 years ago
#3779 new Bugs
Warning using less_equal points to bug
Reported by: | Owned by: | Aleksey Gurtovoy | |
---|---|---|---|
Milestone: | Boost 1.42.0 | Component: | mpl |
Version: | Boost 1.41.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Compiling the following metafunction using VC9 gives a warning which suggests an mpl bug:
#include <boost/mpl/less_equal.hpp> #include <boost/mpl/long.hpp> #include <boost/integer_traits.hpp> namespace nmspace { struct ResultTypeIntegerValues
{ typedef boost::mpl::long_<0L> lzero; typedef boost::mpl::long_<boost::integer_traits<long>::const_min> lmin; typedef boost::mpl::less_equal<lmin,lzero>::type type; };
}
with warning:
c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\integral_wrapper.hpp(73) : warning C4307: '-' : integral constant overflow 1> c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\preprocessed\plain\less_equal.hpp(60) : see reference to class template instantiation 'boost::mpl::long_<N>' being compiled 1> with 1> [ 1> N=-2147483648 1> ] 1> c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\preprocessed\plain\less_equal.hpp(70) : see reference to class template instantiation 'boost::mpl::less_equal_tag<T>' being compiled 1> with 1> [ 1> T=nmspace::ResultTypeIntegerValues::lmin 1> ] 1> c:\programming\programs\xxx\yyy.h(64) : see reference to class template instantiation 'boost::mpl::less_equal<N1,N2>' being compiled 1> with 1> [ 1> N1=nmspace::ResultTypeIntegerValues::lmin, 1> N2=nmspace::ResultTypeIntegerValues::lzero 1> ]
The same warning occurs using Boost 1.41. As Steve Watanabe pointed out the problem looks to be:
typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;
which overflows when one is already at the minimal value. It seems mpl has to take into account the minimal value when using prior and probably the maximal value when using next. In any case I see nothing wrong in the code and therefore I do not think an overflow condition should not be taking place.
#6546 seems to be a duplicate of this bug. I just added some more info there, so it might be good to close this issue?