<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/100498>100498</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++][test] alg.find.last tests assume that `std::array` iterators are pointers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          StephanTLavavej
      </td>
    </tr>
</table>

<pre>
    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:

* [std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last.pass.cpp](https://github.com/llvm/llvm-project/blob/8e43acbfedf53ded43ec693ddaaf518cb7416c1c/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last.pass.cpp)
* [std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if.pass.cpp](https://github.com/llvm/llvm-project/blob/8e43acbfedf53ded43ec693ddaaf518cb7416c1c/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if.pass.cpp)
* [std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if_not.pass.cpp](https://github.com/llvm/llvm-project/blob/8e43acbfedf53ded43ec693ddaaf518cb7416c1c/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if_not.pass.cpp)

Each test emits many errors. I've attached [full_error_logs.txt](https://github.com/user-attachments/files/16369481/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):

<details><summary>Click to expand first error for ranges.find_last.pass.cpp:</summary>

```
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> {
      | ^
```
</details>

<details><summary>Click to expand first error for ranges.find_last_if.pass.cpp:</summary>

```
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>();
      | ^
```
</details>

<details><summary>Click to expand first error for ranges.find_last_if_not.pass.cpp:</summary>

```
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>();
      |   ^
```
</details>

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWk9z274R_TTQBRMOCf4_6CBTUZvpr5fa0ytnRYIifiEBFgAdq4d-9s6CkizJjhKn8jROrOFIJAQC2Ldv32IpgTFiIzmfk_iGxMsZjLZVen5r-dCCvPsD7uGe_zlbq3o7_wevuLTdlgpptarHitd0vaUk8o3VfAMfpOgISw0lLMzzMGAeveUcr9IoCn3aKE0Hze-FGg1txAM3HvGXxF9M73ctp43qOvVFyA213FhDwZix59S2YClJfGNrEi5IuACtYUsSnwrLNVilDQXN6aCEtFwbwgr6pRVVS4WRhKWWbkbQIC2flmxbTm8tyBp0jX1B1rQB0Rm3xr_f_rNwdtze_YHTHa2RsAUl8Q2ug62g2ygtbNub6cKTSvaqFs1WyM2uqRGy9jowlrCVBrnhxjWV2OQNYIxXDQOJl4RlrbWDwfnYirDVRth2XHuV6glbdd39_uPDoNWfvMLx1p1aE7bKeBRCtW543cRhzeso5FWSh3UN0MRBVq3TKEiqoMIBxLp6eCBshegStrq2HSx_BZhK0fwqSJ2Y8lpglVL9MtR6Ys4BNPf-EarWKQXlvbCG9iC3lGuttPHoJ8LSe07BWqhaXiPGzdh1pfu-7NTGePbBfhOg0XD9YRqk59KiIY3oOH4GSZjkURZg0zMjs3yvLS3XnArjdAd70kpJyx-skxvXKDQagfc7U-ykU_xgH2HZX4T967imLRgKNIn-RqsWNFSWa9qJXkyDCWNG7vSv5bLibvDHxeOSzgQtLGpuUfpI-JGEhRn7HvSWhB-LTlSfqVWU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