
Le 29/10/12 20:16, Jeff Flinn a écrit :
I've just downloaded boost_1_52_0_beta1 and get the warning below in my user code on VC11(I'm using thread which evidently brings in the above libs). I didn't see mention of this in trac. I'm moving forward from 1.47 and from VC8 so I'm not sure if this is an indication of some project setting[s] of mine, or if it should be corrected in the lib?
Thanks, Jeff
6>D:\boost_1_52_0_beta1\boost/ratio/detail/overflow_helpers.hpp(136): warning C4293: '<<' : shift count negative or too big, undefined behavior The concerned code is
static const boost::intmax_t nan = (BOOST_RATIO_INTMAX_C(1) << (sizeof(boost::intmax_t) * CHAR_BIT - 1)); I don't reach to see why the shift count could be negative or too big. This is used to emulate some kind of nan for integers and in principle it should not be too risky. You can try to comment the following to avoid the warning template <boost::intmax_t X, boost::intmax_t Y> class br_mul { //static const boost::intmax_t nan = // (BOOST_RATIO_INTMAX_C(1) << (sizeof(boost::intmax_t) * CHAR_BIT - 1)); static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min; static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max; static const boost::intmax_t a_x = mpl::abs_c<boost::intmax_t, X>::value; static const boost::intmax_t a_y = mpl::abs_c<boost::intmax_t, Y>::value; //BOOST_RATIO_STATIC_ASSERT(X != nan, BOOST_RATIO_OVERFLOW_IN_MUL, ()); //BOOST_RATIO_STATIC_ASSERT(Y != nan, BOOST_RATIO_OVERFLOW_IN_MUL, ()); BOOST_RATIO_STATIC_ASSERT(a_x <= max / a_y, BOOST_RATIO_OVERFLOW_IN_MUL, ()); public: static const boost::intmax_t value = X * Y; }; and the warning should disappear. Well note that there are other nan in the file, so them should be commented as well. You can create a ticket to track the issue in case someone finds out the possible hidden bug. Best, Vicente