Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcxx: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>' #4722

Closed
2xsaiko opened this issue Oct 3, 2024 · 5 comments · Fixed by #4726
Labels

Comments

@2xsaiko
Copy link
Contributor

2xsaiko commented Oct 3, 2024

Describe the bug
With LLVM/Clang/libcxx 19.1.0 on Gentoo Linux, POCO fails to compile with the following error:

In file included from /var/tmp/portage/dev-libs/poco-1.13.3/work/poco-poco-1.13.3-release/Data/src/AbstractPreparation.cpp:15:
In file included from /var/tmp/portage/dev-libs/poco-1.13.3/work/poco-poco-1.13.3-release/Data/include/Poco/Data/AbstractPreparation.h:21:
In file included from /var/tmp/portage/dev-libs/poco-1.13.3/work/poco-poco-1.13.3-release/Data/include/Poco/Data/Data.h:23:
In file included from /var/tmp/portage/dev-libs/poco-1.13.3/work/poco-poco-1.13.3-release/Foundation/include/Poco/Foundation.h:94:
/usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
  820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/usr/include/c++/v1/__type_traits/is_constructible.h:42:62: note: in instantiation of template class 'std::basic_string<unsigned char>' requested here
   42 |     : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
      |                                                              ^
/usr/include/c++/v1/__type_traits/is_swappable.h:43:39: note: in instantiation of template class 'std::is_move_constructible<Poco::Data::LOB<unsigned char>>' requested here
   43 | using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>;
      |                                       ^
/usr/include/c++/v1/__type_traits/is_swappable.h:50:60: note: in instantiation of template type alias '__swap_result_t' requested here
   50 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y)
      |                                                            ^
/var/tmp/portage/dev-libs/poco-1.13.3/work/poco-poco-1.13.3-release/Data/include/Poco/Data/LOB.h:243:14: note: while substituting explicitly-specified template arguments into function template 'swap' 
  243 |         inline void swap<Poco::Data::BLOB>(Poco::Data::BLOB& b1, Poco::Data::BLOB& b2) noexcept
      |                     ^
/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^

This error occurs because of this line which instantiates std::basic_string<unsigned char> for BLOB which is not defined in libcxx.

I have a patch here that disables that constructor in case basic_string<T> is not instantiable and fixes compilation.

However I'm not sure if it isn't my system that's hosed in some way since a complete compilation failure would have surely been caught already since libcxx is used for Mac builds, right?

To Reproduce
Compile POCO with clang 19 linking against libcxx.

Expected behavior
POCO compiles

Logs
https://940705.bugs.gentoo.org/attachment.cgi?id=904816

Please add relevant environment information:

  • Gentoo Linux (repository dated Tue, 01 Oct 2024 16:00:00 +0000)
  • POCO Version 1.13.3

Additional context
Gentoo bug 940705

@2xsaiko 2xsaiko added the bug label Oct 3, 2024
@2xsaiko
Copy link
Contributor Author

2xsaiko commented Oct 3, 2024

Ah, this is a new change in libcxx 19: https://bugs.gentoo.org/939897#c0

@matejk
Copy link
Contributor

matejk commented Oct 4, 2024

Poco requires standard C++-17.

IMO the compiler and libcxx that are used to show the reported problem do not handle C++-17 properly.

@2xsaiko
Copy link
Contributor Author

2xsaiko commented Oct 4, 2024

If I look at this correctly, only char_traits<char> is defined in the standard. https://en.cppreference.com/w/cpp/string/char_traits

@matejk
Copy link
Contributor

matejk commented Oct 4, 2024

Your patch looks sane. OTOH it might also make sense to provide LOB ctors only for std::string and std::wstring.

2xsaiko added a commit to 2xsaiko/poco that referenced this issue Oct 4, 2024
This fixes compilation against libcxx 19, which removed the
specialization for std::char_traits<unsigned char>.
See https://reviews.llvm.org/D157058.

Closes pocoproject#4722.
2xsaiko added a commit to 2xsaiko/poco that referenced this issue Oct 4, 2024
This fixes compilation against libcxx 19, which removed the
specialization for std::char_traits<unsigned char>.
See https://reviews.llvm.org/D157058.

Closes pocoproject#4722.
2xsaiko added a commit to 2xsaiko/poco that referenced this issue Oct 4, 2024
This fixes compilation against libcxx 19, which removed the
specialization for std::char_traits<unsigned char>.
See https://reviews.llvm.org/D157058.

Closes pocoproject#4722.
2xsaiko added a commit to 2xsaiko/poco that referenced this issue Oct 4, 2024
This fixes compilation against libcxx 19, which removed the
specialization for std::char_traits<unsigned char>.
See https://reviews.llvm.org/D138307 and
https://reviews.llvm.org/D157058.

Closes pocoproject#4722.
@2xsaiko
Copy link
Contributor Author

2xsaiko commented Oct 4, 2024

I've opened a PR. Feel free to close it if you have a better solution. I tried to add a constructor that takes std::string specifically to LOB with a specialization but then realized specializations don't work like that so I assume that would have to be done using enable_if too :^)

2xsaiko added a commit to 2xsaiko/poco that referenced this issue Oct 4, 2024
This fixes compilation against libcxx 19, which removed the
non-standard specializations for std::char_traits including the one
for unsigned char, which would get instantiated for BLOB.
See https://reviews.llvm.org/D138307 and
https://reviews.llvm.org/D157058.

Closes pocoproject#4722.
@matejk matejk added this to the Release 1.14.0 milestone Oct 7, 2024
@matejk matejk added this to 1.14 Oct 7, 2024
@matejk matejk moved this to In Progress in 1.14 Oct 7, 2024
@matejk matejk closed this as completed in 3b79a51 Oct 7, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 1.14 Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants