Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] picolibc: avoid warning in __locale #73937

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

domin144
Copy link
Contributor

No description provided.

@domin144 domin144 requested a review from a team as a code owner November 30, 2023 13:46
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 30, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 30, 2023

@llvm/pr-subscribers-libcxx

Author: Dominik Wójt (domin144)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/73937.diff

1 Files Affected:

  • (modified) libcxx/include/__locale (+4-2)
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

@domin144
Copy link
Contributor Author

@ldionne @mordante (I cannot request a review in github yet).

This issue slipped in due to race in CI checks between #73396 and https://reviews.llvm.org/D155521 .

Example of failing check:
https://buildkite.com/llvm-project/libcxx-ci/builds/31956#018c1ef2-7088-4da6-b413-63f49a82164b

@ldionne ldionne merged commit 4c338f8 into llvm:main Nov 30, 2023
@domin144 domin144 deleted the libcxx_picolibc_avoid_warning_in_locale branch December 5, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants