Skip to content

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

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

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