| Issue |
107747
|
| Summary |
[libc++] `__wrap_iter<T>` can hijack `operator+`/`operator<` via ADL
|
| Labels |
libc++
|
| Assignees |
|
| Reporter |
MitalAshok
|
With two `T*` pointers, `<`/`-` always has the built-in meaning. But `__wrap_iter` has a `T*` template argument so that adds `T`'s namespace as an associated namespace.
In particular, with `nasty_char` (from <https://github.com/llvm/llvm-project/blob/main/libcxx/test/support/nasty_string.h>),
<https://godbolt.org/z/YT3MvPGd9>:
```c++
static_assert(std::random_access_iterator<nasty_char*>);
static_assert(!std::random_access_iterator<std::__wrap_iter<nasty_char*>>);
static_assert(!std::random_access_iterator<nasty_string::iterator>);
```
Shouldn't use user-overloads for non-pointer types, like `template<typename T> friend bool operator<(T, T)` with `T = __wrap_iter<my_random_access_iterator>`, either.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs