diff --git a/libcxx/include/__locale b/libcxx/include/__locale index dbb9a1f1c81b3..eda81976d7f46 100644 --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -452,16 +452,18 @@ public: #elif defined(_NEWLIB_VERSION) // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. typedef char mask; - static const mask space = _S; - static const mask print = _P | _U | _L | _N | _B; - static const mask cntrl = _C; - static const mask upper = _U; - static const mask lower = _L; - static const mask alpha = _U | _L; - static const mask digit = _N; - static const mask punct = _P; - static const mask xdigit = _X | _N; - static const mask blank = _B; + // In case char is signed, static_cast is needed to avoid warning on + // positive value becomming negative. + static const mask space = static_cast(_S); + static const mask print = static_cast(_P | _U | _L | _N | _B); + static const mask cntrl = static_cast(_C); + static const mask upper = static_cast(_U); + static const mask lower = static_cast(_L); + static const mask alpha = static_cast(_U | _L); + static const mask digit = static_cast(_N); + static const mask punct = static_cast(_P); + static const mask xdigit = static_cast(_X | _N); + static const mask blank = static_cast(_B); // mask is already fully saturated, use a different type in regex_type_traits. static const unsigned short __regex_word = 0x100; # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT