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

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


================
@@ -618,7 +618,7 @@ template <class InternT, class ExternT>
 void utf8_to_utf16_in_error(const std::codecvt<InternT, ExternT, mbstate_t>& cvt) {
   // UTF-8 string of 1-byte CP, 2-byte CP, 3-byte CP, 4-byte CP
   const unsigned char input[] = "b\u0448\uD700\U0010AAAA";
-  const char16_t expected[]   = {'b', 0x0448, 0xD700, 0xDBEA, 0xDEAA, 0};
+  const InternT expected[]    = {0x62, 0x0448, 0xD700, 0xDBEA, 0xDEAA, 0};
----------------
EricWF wrote:

It seems to me that these tests are using the API as it was intended (before it was removed for being bad)?
As in, they are using something like `std::codecvt_utf8_to_utf16` with the char16_t type in their code.

And this set of changes removes test coverage for that case, because it generates the warning about potential narrowing?

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


More information about the llvm-commits mailing list