Boost logo

Boost :

Subject: Re: [boost] [chrono][ratio][boost_1_52_0_beta1] warning in user code
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-10-29 19:15:23

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 =
       static const boost::intmax_t max =

       static const boost::intmax_t a_x = mpl::abs_c<boost::intmax_t,
       static const boost::intmax_t a_y = mpl::abs_c<boost::intmax_t,

       BOOST_RATIO_STATIC_ASSERT(a_x <= max / a_y,
       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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at