[libcxx-commits] [libcxx] [libc++] picolibc: avoid warning in __locale (PR #73937)

Dominik Wójt via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 30 05:46:58 PST 2023


https://github.com/domin144 created https://github.com/llvm/llvm-project/pull/73937

None

>From 3c713b70f5f1617aefbbc88f1c71ae92090695d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <dominik.wojt at arm.com>
Date: Thu, 30 Nov 2023 14:38:28 +0100
Subject: [PATCH] [libc++] picolibc: avoid warning in __locale

---
 libcxx/include/__locale | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index dbb9a1f1c81b3b0..cb87cce6403d433 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -452,8 +452,10 @@ public:
 #elif defined(_NEWLIB_VERSION)
     // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
     typedef char mask;
+    // In case char is signed, static_cast is needed to avoid warning on
+    // positive value becomming negative.
     static const mask space  = _S;
-    static const mask print  = _P | _U | _L | _N | _B;
+    static const mask print  = static_cast<mask>(_P | _U | _L | _N | _B);
     static const mask cntrl  = _C;
     static const mask upper  = _U;
     static const mask lower  = _L;
@@ -461,7 +463,7 @@ public:
     static const mask digit  = _N;
     static const mask punct  = _P;
     static const mask xdigit = _X | _N;
-    static const mask blank  = _B;
+    static const mask blank  = static_cast<mask>(_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



More information about the libcxx-commits mailing list