[libcxx-commits] [PATCH] D144346: [libc++][format] Improves Unicode decoders.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 8 08:55:12 PST 2023


Mordante accepted this revision.
Mordante marked an inline comment as done.
Mordante added a comment.
This revision is now accepted and ready to land.

Thanks for the reviews. I'll apply the fixes and land it when the CI is green.



================
Comment at: libcxx/include/__format/unicode.h:266
 
+    char32_t __value = *__first_++;
     if constexpr (sizeof(wchar_t) == 2) {
----------------
tahonermann wrote:
> It is implementation-defined whether `wchar_t` is a signed type so I think a cast to an unsigned type is needed here and in other cases below where `first` is dereferenced.
> 
> This would be a good use case for a `std::as_unsigned()` or `std::to_unsigned()` function.
I think it's not needed here, but on line 277 it indeed might be a good idea. For consistency I did it at all places. I think a `static_cast` is fine, I did the same for `char`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144346/new/

https://reviews.llvm.org/D144346



More information about the libcxx-commits mailing list