@@ -452,16 +452,18 @@ public:
452452#elif defined(_NEWLIB_VERSION)
453453 // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
454454 typedef char mask;
455- static const mask space = _S;
456- static const mask print = _P | _U | _L | _N | _B;
457- static const mask cntrl = _C;
458- static const mask upper = _U;
459- static const mask lower = _L;
460- static const mask alpha = _U | _L;
461- static const mask digit = _N;
462- static const mask punct = _P;
463- static const mask xdigit = _X | _N;
464- static const mask blank = _B;
455+ // In case char is signed, static_cast is needed to avoid warning on
456+ // positive value becomming negative.
457+ static const mask space = static_cast <mask>(_S);
458+ static const mask print = static_cast <mask>(_P | _U | _L | _N | _B);
459+ static const mask cntrl = static_cast <mask>(_C);
460+ static const mask upper = static_cast <mask>(_U);
461+ static const mask lower = static_cast <mask>(_L);
462+ static const mask alpha = static_cast <mask>(_U | _L);
463+ static const mask digit = static_cast <mask>(_N);
464+ static const mask punct = static_cast <mask>(_P);
465+ static const mask xdigit = static_cast <mask>(_X | _N);
466+ static const mask blank = static_cast <mask>(_B);
465467 // mask is already fully saturated, use a different type in regex_type_traits.
466468 static const unsigned short __regex_word = 0x100 ;
467469# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
0 commit comments