[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 14 14:41:44 PDT 2025


================
@@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __encode(_OutIt& __out_it, char32_t __value
   _LIBCPP_ASSERT_UNCATEGORIZED(__is_scalar_value(__value), "an invalid unicode scalar value results in invalid UTF-16");
 
   if (__value < 0x10000) {
-    *__out_it++ = __value;
+    *__out_it++ = static_cast<iter_value_t<_OutIt>>(__value);
----------------
EricWF wrote:

To be clear, this static cast will never change the value when the assertion above is enabled, right? Because we catch the potential narrowing there?

https://github.com/llvm/llvm-project/pull/138708


More information about the cfe-commits mailing list