[libcxx] Don't truncate intermediates to wchar_t when widening
authorMartin Storsjö <martin@martin.st>
Tue, 27 Oct 2020 11:01:54 +0000 (13:01 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 27 Oct 2020 21:58:27 +0000 (23:58 +0200)
On windows, wchar_t is 16 bit, while we might be widening chars to
char32_t.

This cast had been present since the initial commit, and removing it
doesn't seem to make any tests fail.

Differential Revision: https://reviews.llvm.org/D90228

libcxx/include/__locale

index 48e7b64..90be8bb 100644 (file)
@@ -1412,7 +1412,7 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
             if (__r == codecvt_base::error || __nn == __nb)
                 __throw_runtime_error("locale not supported");
             for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
-                *__s = (wchar_t)*__p;
+                *__s = *__p;
             __nb = __nn;
         }
         return __s;
@@ -1446,7 +1446,7 @@ struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
             if (__r == codecvt_base::error || __nn == __nb)
                 __throw_runtime_error("locale not supported");
             for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
-                *__s = (wchar_t)*__p;
+                *__s = *__p;
             __nb = __nn;
         }
         return __s;