Boost logo

Boost Users :

Subject: [Boost-users] [Regex] 1.37.0: Truncation warning under Windows
From: Peter Klotz (Peter.Klotz_at_[hidden])
Date: 2008-11-07 07:09:41


MSCV8 gives this warning when compiling Boost.Regex 1.37.0 under Windows x86 (32 Bit):

libs\regex\src\..\src\cregex.cpp(563) : warning C4309: 'static_cast' : truncation of constant value

The code that produces the warning:

#ifdef BOOST_HAS_LONG_LONG
const std::size_t RegEx::npos = static_cast<std::size_t>(~0ULL);
#else
const std::size_t RegEx::npos = static_cast<std::size_t>(~0UL);
#endif

In Windows x86 sizeof(unsigned long long int) is 8, sizeof(std::size_t) is 4 and BOOST_HAS_LONG_LONG is defined.

Therefore "~0ULL" is truncated from 8 to 4 bytes.

Maybe a better trigger would be the architecture (32 Bit or 64 Bit) since in all environments I know sizeof(std::size_t) equals the architecture.

Regards, Peter.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net