Skip to content

[libc++][test] alg.find.last tests assume that std::array iterators are pointers #100498

@StephanTLavavej

Description

@StephanTLavavej

Recently introduced by @strega-nil's #99312. See #74430 for previous fixes.

The following tests assume that std::array iterators are pointers, which isn't guaranteed by the Standard, and fails for MSVC's STL:

Each test emits many errors. I've attached full_error_logs.txt, and here is the full context for the first error emitted by each test (GitHub has a 64K character limit for issues, hence the attachment):

Click to expand first error for ranges.find_last.pass.cpp:
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp(64,34): error: cannot cast from type 'iterator' (aka '_Array_iterator<char, 0>') to pointer type 'char *'
   64 |     return std::ranges::subrange(It(std::ranges::begin(a)), Sent(It(std::ranges::end(a))));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp(93,41): note: in instantiation of function template specialization 'test_iterators()::(anonymous class)::operator()<std::array<char, 0>>' requested here
   93 |       auto ret = std::ranges::find_last(make_range(a), 1).begin();
      |                                         ^
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp(163,7): note: in instantiation of function template specialization 'test_iterators<char *, char *>' requested here
  163 |       test_iterators<Iter>();
      |       ^
D:\GitHub\STL\llvm-project\libcxx\test\support/type_algorithms.h(52,23): note: in instantiation of function template specialization 'test()::(anonymous class)::operator()()::(anonymous class)::operator()<char *>' requested here
   52 |   swallow((f.template operator()<Types>(), 0)...);
      |                       ^
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp(162,12): note: in instantiation of function template specialization 'types::for_each<char *, contiguous_iterator<char *>, random_access_iterator<char *>, bidirectional_iterator<char *>, forward_iterator<char *>, (lambda at D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp:162:57)>' requested here
  162 |     types::for_each(types::forward_iterator_list<T*>{}, []<class Iter> {
      |            ^
D:\GitHub\STL\llvm-project\libcxx\test\support/type_algorithms.h(52,23): note: in instantiation of function template specialization 'test()::(anonymous class)::operator()<char>' requested here
   52 |   swallow((f.template operator()<Types>(), 0)...);
      |                       ^
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp(161,10): note: in instantiation of function template specialization 'types::for_each<char, int, TriviallyComparable<char>, (lambda at D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last.pass.cpp:161:77)>' requested here
  161 |   types::for_each(types::type_list<char, int, TriviallyComparable<char>>{}, []<class T> {
      |          ^
Click to expand first error for ranges.find_last_if.pass.cpp:
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if.pass.cpp(62,32): error: cannot cast from type 'iterator' (aka '_Array_iterator<int, 0>') to pointer type 'const std::_Array_iterator<int, 0> *'
   62 |   return std::ranges::subrange(It(std::ranges::begin(a)), Sent(It(std::ranges::end(a))));
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if.pass.cpp(101,44): note: in instantiation of function template specialization 'make_range<const std::_Array_iterator<int, 0> *, const std::_Array_iterator<int, 0> *, std::array<int, 0>>' requested here
  101 |       auto ret = std::ranges::find_last_if(make_range<it, sent>(a), [](auto&&) { return true; }).begin();
      |                                            ^
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if.pass.cpp(191,3): note: in instantiation of function template specialization 'test_iterator_classes<add_const_to_ptr_t, std::type_identity_t>' requested here
  191 |   test_iterator_classes<add_const_to_ptr_t, std::type_identity_t>();
      |   ^
Click to expand first error for ranges.find_last_if_not.pass.cpp:
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if_not.pass.cpp(62,32): error: cannot cast from type 'iterator' (aka '_Array_iterator<int, 0>') to pointer type 'const std::_Array_iterator<int, 0> *'
   62 |   return std::ranges::subrange(It(std::ranges::begin(a)), Sent(It(std::ranges::end(a))));
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if_not.pass.cpp(101,48): note: in instantiation of function template specialization 'make_range<const std::_Array_iterator<int, 0> *, const std::_Array_iterator<int, 0> *, std::array<int, 0>>' requested here
  101 |       auto ret = std::ranges::find_last_if_not(make_range<it, sent>(a), [](auto&&) { return false; }).begin();
      |                                                ^
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if_not.pass.cpp(191,3): note: in instantiation of function template specialization 'test_iterator_classes<add_const_to_ptr_t, std::type_identity_t>' requested here
  191 |   test_iterator_classes<add_const_to_ptr_t, std::type_identity_t>();
      |   ^

Metadata

Metadata

Assignees

Labels

libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.test-suite

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions