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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] `__wrap_iter<T>` can hijack `operator+`/`operator<` via ADL
        </td>
    </tr>

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

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

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

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

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVF2P4jYU_TXOiwUy1yEfD3lgYFJV6kqVilT1Cd0khnjHsSP7Bpb--sqBZZi2o6rSSsYg3-_DORdD0CerVMXWL2y9S3Ci3vnqiyY0m9C7t6Rx3bX6XVPP6eI4y8SewYZlgo9OW1I-MNjGZya38YaaZWIR7WgueA28x8CpV7yZtKGFtnxQaLU9LfnLRDHwcLh4HA-alI9h0R-f65AaRoOkOPrTNChLPDhOPRLHrgs3z1g4D9zioMKIreIxieUYgms1kureTUsmdkxsbvfPlo_oSbeTQR8HucRBWSYsBroe2h7nnhgUR-8GzuS2JxoDk5s4KNQnTf3ULFs3MKiNOX__WozefVUtMagb4xoG9YDaRqNu2m_fGNSkQrSGaRydj79uFQP5iE3P5CuDksH2udt_lndd4wwtnT8xqP9kUP-xl1_Ov_7UlTGB3HyIzsTttAxe4plfAyHp9oAhqNhGEaiLcXLj0XZuOGDbqhDmfwfJeSa3T9DA5t6n_CQbg9V_J3x4PDPhX-r8gFLPIN9c340fsj_Aekbwt95NprMMcuJTUPHjF-6svHHYBX50nltnF3dhcLqOalaH0W8qkuo7k5ncRlukJN8z-cqPXivb8cY5w9346JZBsY_x-9hZJh7k3HMmd_wjWsP18NnUr7M8tlxp6pW_8z_pKtmVssREVasc1nmxXmdp0lfHLkNIc1kU4pgpIdKiXGV5C2pV5plKj4muQEAqSlGIYg1pulyV8ogAJUAhQYiWpUINqM0yKiFyM9EhTKpaiTxP88Rgo0yYFw5A1MOdjgBxAflq1k8znQJLhdGBwnse0mTmVfUUtt79fYnI7f42NG_R8l5_xfYt-jyQhZfHpnpGOxP8rJFvdr8kkzfV_1b6PGVgUN8HPVfwVwAAAP__WVGsTA">