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

    <tr>
        <th>Summary</th>
        <td>
            `<algorithm>`: `ranges::binary_search`'s return statement is wrong
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    https://github.com/llvm/llvm-project/blob/8d06a7098588a7375d727a3bf826b2aa2e8f75c1/libcxx/include/__algorithm/ranges_binary_search.h#L34-L40

`!std::invoke(__comp, __value, std::invoke(__proj, *__first))` has a typo, we should compare `*__ret` instead of `*__first`.

simple test: https://godbolt.org/z/jqr9ajh9d
```
#include <algorithm>

constexpr int r[] = {1, 2, 4};
static_assert(!std::ranges::binary_search(r, 3));
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU01zpCAQ_TXthcoUNirOwYPJrKf8BwulVRJGZgEzyf76LWYmH5vaPWwVhUh3vX79-qFCMPNK1EB5D-UhU1tcnG8WOhtrn7PB6bdmifEUQLSAHWA3m7hsw250R8DO2pf3z93JuycaI2A3WDcAdrXmlZJ8X5d1raSQpZYolRimGqsBlUKqJ1mOeQIww_j6CtiZdbSbJsCu75WdnTdxSRW8WmcK_WBW5d_6QMqPy24BFI-iuHssOPAD8Pa2VxwwD1EnzqI164t7JsC670d3PAE-sL5_UXajdPxbWuokxQDbvp-MDxFwn1bF2aICUyy-nVzKOBMLi9usZglaeWKX4m3fe4op3awhktLMTR-RK2DFd185B3M8WWKRQgTRsm-SOz04G3fOz4DdL8Du6affq6dlrz87vq7rL4qbjgzEw6eM4sfXkqNL3F5Pnpk1Mn81AANxYCDv89Qdpq0AeQBxf6MZVTRjr0IgHwHrrzpfR3Q9_zEnwNonJHFT8R3sg3WmG6H3Yq8yavJKyrqsRCGypam0wAIRp7woNdfTUAjMiXOOUzkqLTPTIEfBBRd5mSOKnaj0UE2CF0pKoQoFBaejMnaXLJoEzEwIGzVVnlc8s2ogGy7eR1zpzC5BQExPwTcXWw_bHKDg1oQYPlGiiZaaRP-bwOmmTbP-txzJBzIwT3HzK0uS0pHWyExgZ-_WOdu8_f9Hd6EeALtLa78DAAD__7TtKaU">