Boost logo

Boost :

Subject: [boost] [xpressive] Significant compiler warning
From: Ian Emmons (iemmons_at_[hidden])
Date: 2009-11-25 11:35:25


I have a program that uses Boost.Xpressive. When compiling this code on the Macintosh with the darwin-4.2.1 toolset, I get the following compiler warning:

    .../boost_1_41_0/boost/xpressive/traits/cpp_regex_traits.hpp:84:
    warning: left shift count >= width of type

Here is the offending line of code:

    umaskex_t const highest_bit = 1
        << (sizeof(umaskex_t) * CHAR_BIT - 1);

The problem (if my thinking cap is screwed on correctly) is that the 1 that is being shifted is of type int, and is not converted to the target type of umaskex_t until after the shift operation. I believe that this should be changed to the following to avoid highest_bit being set to zero:

    umaskex_t const highest_bit = static_cast<umaskex_t>(1)
        << (sizeof(umaskex_t) * CHAR_BIT - 1);




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