Skip to content

[C++] basic_string_view<long> will be invalid in future libc++ #15281

Closed

Description

@jyknight

Describe the bug, including details regarding any error messages, version, and platform.

Libc++ has made a change to stop supporting std::char_traits (and thus, also, basic_string and basic_string_view) for non-character types: https://discourse.llvm.org/t/deprecating-std-string-t-for-non-character-t/66779

Apparently, such support was never required by the standard, and is considered a mistake.

The initial libc++ change made this a hard error, but after reports of breakage, it was downgraded to a deprecation warning. See review thread https://reviews.llvm.org/D138307. It is now expected to become a hard error again in LLVM 18.

One of the projects broken is Apache Arrow, due to the usage here:

using View = util::basic_string_view<Word>;

E.g.,

/usr/include/c++/v1/string_view:279:45: error: implicit instantiation of undefined template 'std::char_traits<unsigned long>'
    static_assert((is_same<_CharT, typename traits_type::char_type>::value),
                                            ^
arrow/util/bitmap.h:153:16: note: in instantiation of template class 'std::basic_string_view<unsigned long>' requested here
    View<Word> words[N];
               ^
arrow/compute/kernels/scalar_if_else.cc:1595:15: note: in instantiation of function template specialization 'arrow::internal::Bitmap::VisitWords<3UL, (lambda at arrow/compute/kernels/scalar_if_else.cc:1595:35), unsigned long>' requested here
      Bitmap::VisitWords(bitmaps, [&](std::array<uint64_t, 3> words) {
              ^
arrow/compute/kernels/scalar_if_else.cc:1652:14: note: in instantiation of function template specialization 'arrow::compute::internal::(anonymous namespace)::ExecArrayCaseWhen<arrow::BooleanType>' requested here
      return ExecArrayCaseWhen<Type>(ctx, batch, out);
             ^
arrow/compute/kernels/codegen_internal.h:1173:47: note: in instantiation of member function 'arrow::compute::internal::(anonymous namespace)::CaseWhenFunctor<arrow::BooleanType>::Exec' requested here
      return Generator<BooleanType, Args...>::Exec;
                                              ^
arrow/compute/kernels/scalar_if_else.cc:2738:17: note: in instantiation of function template specialization 'arrow::compute::internal::GenerateTypeAgnosticPrimitive<arrow::compute::internal::(anonymous namespace)::CaseWhenFunctor>' requested here
    auto exec = GenerateTypeAgnosticPrimitive<CaseWhenFunctor>(*type);

I suspect "View" needs to be changed to use some other type than std::basic_string_view (could be std::span if you required c++20, but you probably don't want to require c++20 yet.)

Component(s)

C++

Activity

  1. westonpace commented on Jan 21, 2023

    @westonpace
    Member

    Normally I think we'd want to setup a CI to regress this sort of thing. However, clang-18 is not yet released. Do you have any suggestion on how this could be regressed?

  2. changed the title [-]basic_string_view<long> will be invalid in future libc++[/-] [+][C++] basic_string_view<long> will be invalid in future libc++[/+] on Jan 21, 2023
  3. self-assigned this
    on Jun 27, 2023
  4. bkietz commented on Jun 27, 2023

    @bkietz
    Member

    Span is relatively straightforward, I'll write a basic impl and refactor Bitmap.

  5. added a commit that references this issue on Jul 11, 2023
  6. added a commit that references this issue on Jul 11, 2023
  7. added this to the 13.0.0 milestone on Jul 11, 2023
  8. raulcd commented on Jul 11, 2023

    @raulcd
    Member

    @pitrou this has been tagged as 13.0.0, were you expecting this to be added to the release?

  9. pitrou commented on Jul 11, 2023

    @pitrou
    Member

    No, sorry. You can untag it.

  10. modified the milestones: 13.0.0, 14.0.0 on Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions