[libcxx-commits] [libcxx] Enable identification of code that relies on std::char_traits<char16_t>::int_type. (PR #89840)

Jordan Rupprecht via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 24 08:50:51 PDT 2024


rupprecht wrote:

This breaks instantiation of `std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>`, i.e. https://godbolt.org/z/6ees97naz. Several different OSS projects have a snippet like this: https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/8d7f25b13b5efb3695a37b9a3c7e2b65be5c2de2/src/libutil/strutil.cpp#L941

The error looks like:
```
.../include/c++/v1/locale:3121:46: error: 'int_type' is a private member of 'std::char_traits<char16_t>'
 3121 |   typedef typename wide_string::traits_type::int_type int_type;
      |                                              ^
.../openimageio/src/libutil/strutil.cpp:929:75: note: in instantiation of template class 'std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>' requested here
  929 |         std::wstring_convert, char16_t> conv;
      |                                                                           ^
.../include/c++/v1/__string/char_traits.h:346:9: note: declared private here
  346 |   using int_type   = uint_least16_t;
      |         ^
1 error generated.
```

One of the snippets has a comment acknowledging that these methods are deprecated (i.e. fails with `-Wdeprecated-declarations` in clang/libc++), but notes that there is no clear alternative.

The only other kind of breakage I see is in boost, due to the instantiation here: https://github.com/boostorg/log/blob/38bf38e835d968ac306800b6f46f4d63a04346bb/src/dump.cpp#L121

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


More information about the libcxx-commits mailing list