[libcxx-commits] [libcxx] 70bba9e - [libcxx] Don't truncate intermediates to wchar_t when widening

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 27 14:59:09 PDT 2020


Author: Martin Storsjö
Date: 2020-10-27T23:58:27+02:00
New Revision: 70bba9ef3530b4a45fba1aabe413b56d7b54cc9f

URL: https://github.com/llvm/llvm-project/commit/70bba9ef3530b4a45fba1aabe413b56d7b54cc9f
DIFF: https://github.com/llvm/llvm-project/commit/70bba9ef3530b4a45fba1aabe413b56d7b54cc9f.diff

LOG: [libcxx] Don't truncate intermediates to wchar_t when widening

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

Added: 
    

Modified: 
    libcxx/include/__locale

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index 48e7b642f884..90be8bbe0eef 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -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;


        


More information about the libcxx-commits mailing list