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

    <tr>
        <th>Summary</th>
        <td>
            `bugprone-nondeterministic-pointer-iteration-order` reported with custom comparator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy,
            false-positive
      </td>
    </tr>

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

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

<pre>
    ```cpp
#include <algorithm>
#include <vector>

struct S
{
    int i() const;
};

void f()
{
    std::vector<const S*> v;
    std::sort(v.begin(), v.end(), [](const S* s1, const S* s2){
        return s1->i() > s2->i();
 });
}
```

```
<source>:12:5: warning: sorting pointers is nondeterministic [bugprone-nondeterministic-pointer-iteration-order]
   12 | std::sort(v.begin(), v.end(), [](const S* s1, const S* s2){
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   13 | return s1->i() > s2->i();
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
   14 | });
```
https://godbolt.org/z/xjYe63rY6

This is only reported with libc++.

The warning should not be reported if a custom compare function is provided.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE2P4ygQ_TXlC3KEizhxDj446c4fmL3MEUPFZkTAAuze3sP-9hWJ0197WPUeBkUKRRWv6r1nIWM0gyNqoT5C_VTIOY0-tBcT6EUuVPRev7aw4_efmibgHaAwTtlZEwNxknbwwaTxCuL5X8mFVPJhzfAupjCrxH7kaH8E3jHGmHGJGcAG8MCUdzGBON4KntYN7xZvNLvcaz7djUmD6EB0j0anGwL7AdiBeGbLHeJTafQhATbLpqfBuBUUT2zZkNPv4V0QwOYdkcUqZz4eYK5-GyevQGkOjsWqBPH84JVnifjhZJ0rk3wEec-7N63vzD-F4hT9HBRlPUVXIYiuBtGxFxmccUPeZnLGDWzyxiUKkZnInHeaEoWrcSYmozK1fh6m4B2VX5PlerM0iYJMxrvSB00ha3EjWSGD_ek3yZk7Qf389_9e68zihvQta976P9Z_9djep_3o6AfzxpSmmBXDM-B58Lr3Nm18GADPfwGe__z1k3Yi_Nzdff9jNDfvvLOvLNDkQyLNXkwamTW9AjwCHjePWnp8AiyOfraaOZ9YT-8XzYVJpuaY_JUpf51kIHaZncr-5jZT8IvRpDeFboU-iIMsqK32NW-2-7qpirHlUhLfN82h5xfc16rSUmmUjT70NXGsC9Mix5rvsK64EJxvDnIrK-p3h6raCpIX2HK6SmM31i7XzLwwMc7UVtt6t6sLK3uy8fYOISor3VAmo18BEfAEiBdpI5WTjyaZhfJx_VSENoOV_TxE2HJrYorv8MkkS_nx-v7HvuNfRP-knUw-FHOw7RdTTRrnfqP8FfCcp1j_yin4X6QS4PnGOAKeV9JLi_8EAAD__4DerrA">