diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -1567,7 +1567,7 @@ __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); - if (__nb == nullptr) + if (__nc == -1) __throw_bad_alloc(); __nbh.reset(__nb); } @@ -1618,7 +1618,7 @@ __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); - if (__nb == nullptr) + if (__nc == -1) __throw_bad_alloc(); __nbh.reset(__nb); } @@ -3392,17 +3392,17 @@ char* __bb = __buf; char_type __digits[__bs]; char_type* __db = __digits; - size_t __n = static_cast(snprintf(__bb, __bs, "%.0Lf", __units)); + int __n = snprintf(__bb, __bs, "%.0Lf", __units); unique_ptr __hn(nullptr, free); unique_ptr __hd(0, free); // secure memory for digit storage - if (__n > __bs-1) + if (static_cast(__n) > __bs-1) { - __n = static_cast(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units)); - if (__bb == nullptr) + __n = __libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units); + if (__n == -1) __throw_bad_alloc(); __hn.reset(__bb); - __hd.reset((char_type*)malloc(__n * sizeof(char_type))); + __hd.reset((char_type*)malloc(static_cast(__n) * sizeof(char_type))); if (__hd == nullptr) __throw_bad_alloc(); __db = __hd.get(); @@ -3424,9 +3424,9 @@ char_type __mbuf[__bs]; char_type* __mb = __mbuf; unique_ptr __hw(0, free); - size_t __exn = static_cast(__n) > __fd ? - (__n - static_cast(__fd)) * 2 + __sn.size() + - __sym.size() + static_cast(__fd) + 1 + size_t __exn = __n > __fd ? + (static_cast(__n) - static_cast(__fd)) * 2 + + __sn.size() + __sym.size() + static_cast(__fd) + 1 : __sn.size() + __sym.size() + static_cast(__fd) + 2; if (__exn > __bs) {