[mpl] Strange integral constant overflow warning in mpl::less_equal
This simplified version of some TMP code I am writing using mpl and integer_traits is giving me a strange warning. I'm using VC9 and Boost 1.40: ------------------------------------------------------------------------------------- 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 message: ------------------------------------------------------------------------------------- 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> ] ------------------------------------------------------------------------------------- As far as I can see I am doing a perfectly valid comparison. Is this a minor bug in mpl or am I doing something wrong or should this warning just be expected ? Warning C4307 gives: ------------------------------------------------------------------------------------- Error Message 'operator' : integral constant overflow The operator is used in an expression that results in an integer constant overflowing the space allocated for it. You may need to use a larger type for the constant. A signed int holds a smaller value than an unsigned int because the signed int uses one bit to represent the sign. The following sample generates C4307: // C4307.cpp // compile with: /W2 int i = 2000000000 + 2000000000; // C4307 int j = (unsigned)2000000000 + 2000000000; // OK int main() { } -------------------------------------------------------------------------------------
AMDG Edward Diener wrote:
This simplified version of some TMP code I am writing using mpl and integer_traits is giving me a strange warning. I'm using VC9 and Boost 1.40:
-------------------------------------------------------------------------------------
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; };
The problem is the prior typedef. typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior; In Christ, Steven Watanabe
Steven Watanabe wrote:
AMDG
Edward Diener wrote:
This simplified version of some TMP code I am writing using mpl and integer_traits is giving me a strange warning. I'm using VC9 and Boost 1.40:
-------------------------------------------------------------------------------------
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; };
The problem is the prior typedef.
typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;
I agree. Is this not a bug in mpl ?
participants (2)
-
Edward Diener
-
Steven Watanabe