Skip to content

Can't compile using llvm's libcxx: implicit instantiation of undefined template 'std::char_traits<int>' #353

@StormBytePP

Description

@StormBytePP

When compiling using clang and libcxx as C++ library there are errors caused by the removal of generic char_traits by LLVM D157058 :

clang++ -I. -std=c++11 -O2 -pipe -march=native  \
	-o dictgen dict-generate.cpp -Wl,-z,pack-relative-relocs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -Wl,-O2 -Wl,--sort-common -Wl,-z,separate-code -Wl,-z,noexecstack -fuse-ld=lld -Wl,--thinlto-jobs=all -Wl,--build-id=uuid -Wl,--icf=safe
In file included from dict-generate.cpp:26:
In file included from /usr/include/c++/v1/iostream:45:
In file included from /usr/include/c++/v1/ios:223:
In file included from /usr/include/c++/v1/__locale:27:
/usr/include/c++/v1/string:834:42: error: implicit instantiation of undefined template 'std::char_traits<int>'
  834 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
dict-generate.cpp:862:18: note: in instantiation of template class 'std::basic_string<int>' requested here
  862 |     StringOfInts Chld;
      |                  ^
/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 dict-generate.cpp:26:
In file included from /usr/include/c++/v1/iostream:45:
In file included from /usr/include/c++/v1/ios:223:
In file included from /usr/include/c++/v1/__locale:27:
In file included from /usr/include/c++/v1/string:652:
/usr/include/c++/v1/string_view:306:42: error: implicit instantiation of undefined template 'std::char_traits<int>'
  306 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/usr/include/c++/v1/__type_traits/is_convertible.h:23:60: note: in instantiation of template class 'std::basic_string_view<int>' requested here
   23 |     : public integral_constant<bool, __is_convertible(_T1, _T2)> {};
      |                                                            ^
/usr/include/c++/v1/string:750:29: note: in instantiation of template class 'std::is_convertible<const int &, std::basic_string_view<int>>' requested here
  750 |     : public _BoolConstant< is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
      |                             ^
/usr/include/c++/v1/string:1368:27: note: in instantiation of template class 'std::__can_be_converted_to_string_view<int, std::char_traits<int>, int>'
      requested here
 1368 |             __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
      |                           ^
/usr/include/c++/v1/string:1372:3: note: while substituting prior template arguments into non-type template parameter [with _Tp = int]
 1372 |   operator+=(const _Tp& __t) {
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1373 |     __self_view __sv = __t;
      |     ~~~~~~~~~~~~~~~~~~~~~~~
 1374 |     return append(__sv);
      |     ~~~~~~~~~~~~~~~~~~~~
 1375 |   }
      |   ~
dict-generate.cpp:872:14: note: while substituting deduced template arguments into function template 'operator+=' [with _Tp = int, $1 = (no value)]
  872 |         Chld += i;
      |              ^
/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions