[libcxx-commits] [libcxx] [libcxx][test] Do not assume array::iterator is a pointer (PR #100603)

Stephan T. Lavavej via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 25 15:56:12 PDT 2024


StephanTLavavej wrote:

@strega-nil There are still errors with MSVC's STL. Full logs: [clang_errors.txt](https://github.com/user-attachments/files/16384329/clang_errors.txt)

Here's my analysis of the first error, which is:

```
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if.pass.cpp(104,21): error: cannot cast from type 'iterator' (aka '_Array_iterator<int, 0>') to pointer type 'it' (aka 'const std::_Array_iterator<int, 0> *')
  104 |       assert(ret == it(a.begin()));
      |                     ^~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\assert.h(40,17): note: expanded from macro 'assert'
   40 |             (!!(expression)) ||                                                              \
      |                 ^~~~~~~~~~
D:\GitHub\STL\llvm-project\libcxx\test\std\algorithms\alg.nonmodifying\alg.find.last\ranges.find_last_if.pass.cpp(193,3): note: in instantiation of function template specialization 'test_iterator_classes<add_const_to_ptr_t, std::type_identity_t>' requested here
  193 |   test_iterator_classes<add_const_to_ptr_t, std::type_identity_t>();
      |   ^
```

https://github.com/strega-nil/llvm-project/blob/04a67b5617d11a94627c5ee89f24e2fff9ce8eda/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if.pass.cpp#L104

https://github.com/strega-nil/llvm-project/blob/04a67b5617d11a94627c5ee89f24e2fff9ce8eda/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.last/ranges.find_last_if.pass.cpp#L188-L193

It appears that `add_const_to_ptr_t` contains the assumption, since it's using `remove_pointer_t` on an array iterator.

https://github.com/llvm/llvm-project/pull/100603


More information about the libcxx-commits mailing list