libc++-19: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
OS: Gentoo Linux amd64 musl/clang
$ clang --version
clang version 19.0.0git78b4e7c5+libcxx
Target: x86_64-gentoo-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/19/bin
Configuration file: /etc/clang/x86_64-gentoo-linux-musl-clang.cfg
Compiling poppler-9999
fails with the following error:
[269/283] /usr/lib/ccache/bin/clang++ -Dpoppler_cpp_EXPORTS -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999 -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/fofi -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/goo -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/poppler -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999_build -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999_build/poppler -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999_build/cpp -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O3 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -flto -stdlib=libc++ -Wnon-virtual-dtor -Woverloaded-virtual -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o -MF cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o.d -o cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o -c /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-destination.cpp
FAILED: cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o
/usr/lib/ccache/bin/clang++ -Dpoppler_cpp_EXPORTS -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999 -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/fofi -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/goo -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/poppler -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999_build -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999_build/poppler -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp -I/var/tmp/portage/app-text/poppler-9999/work/poppler-9999_build/cpp -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O3 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -flto -stdlib=libc++ -Wnon-virtual-dtor -Woverloaded-virtual -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o -MF cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o.d -o cpp/CMakeFiles/poppler-cpp.dir/poppler-destination.cpp.o -c /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-destination.cpp
In file included from /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-destination.cpp:24:
In file included from /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-destination.h:25:
In file included from /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-global.h:32:
/usr/include/c++/v1/string:730:43: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
730 | static_assert((is_same<_CharT, typename traits_type::char_type>::value),
| ^
/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-global.h:101:43: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
101 | class POPPLER_CPP_EXPORT ustring : public std::basic_string<unsigned short>
| ^
/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
| ^
In file included from /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-destination.cpp:24:
In file included from /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-destination.h:25:
In file included from /var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-global.h:32:
In file included from /usr/include/c++/v1/string:625:
/usr/include/c++/v1/string_view:296:43: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
296 | static_assert((is_same<_CharT, typename traits_type::char_type>::value),
| ^
/usr/include/c++/v1/__type_traits/is_convertible.h:28:102: note: in instantiation of template class 'std::basic_string_view<unsigned short>' requested here
28 | struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible(_T1, _T2)> {};
| ^
/usr/include/c++/v1/string:702:29: note: in instantiation of template class 'std::is_convertible<const std::basic_string<unsigned short> &, std::basic_string_view<unsigned short>>' requested here
702 | : public _BoolConstant< is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
| ^
/usr/include/c++/v1/string:1044:27: note: in instantiation of template class 'std::__can_be_converted_to_string_view<unsigned short, std::char_traits<unsigned short>, std::basic_string<unsigned short>>' requested here
1044 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
| ^
/usr/include/c++/v1/string:1047:93: note: while substituting prior template arguments into non-type template parameter [with _Tp = std::basic_string<unsigned short>]
1047 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1048 | : __r_(__default_init_tag(), __default_init_tag()) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1049 | __self_view __sv = __t;
| ~~~~~~~~~~~~~~~~~~~~~~~
1050 | __init(__sv.data(), __sv.size());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1051 | }
| ~
/usr/include/c++/v1/string:709:7: note: while substituting deduced template arguments into function template 'basic_string' [with _Tp = std::basic_string<unsigned short>, $1 = (no value)]
709 | class basic_string {
| ^
/var/tmp/portage/app-text/poppler-9999/work/poppler-9999/cpp/poppler-global.h:101:26: note: while declaring the implicit copy constructor for 'ustring'
101 | class POPPLER_CPP_EXPORT ustring : public std::basic_string<unsigned short>
| ^
/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
| ^
2 errors generated.
ninja: build stopped: subcommand failed.
The generic char_traits implementation has been deprecated in LLVM 17 and removed in https://github.com/llvm/llvm-project/commit/c3668779c13596e223c26fbd49670d18cd638c40.