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:

const std::size_t RegEx::npos = static_cast<std::size_t>(~0ULL);
const std::size_t RegEx::npos = static_cast<std::size_t>(~0UL);

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, kalb at, bjorn.karlsson at, gregod at, wekempf at