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

    <tr>
        <th>Summary</th>
        <td>
            constraints ignored on overloaded global 'operator=='
        </td>
    </tr>

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

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

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

<pre>
    While trying to implement a global operator== for a specific type 
combination, clang seems to ignore the given constraints.

The reduced test-case (https://godbolt.org/z/hnY8MjavY)
```
#include <cstdint>
#include <iostream>
        
template <typename T>
struct result {
    T value;
    bool failed;

    constexpr operator const T&() const noexcept { return value; }
};

template <typename T>
    requires(false)
inline constexpr bool operator==(T lhs, bool rhs) noexcept {
    return static_cast<bool>(lhs) == rhs;
}

result<std::size_t> fn() { return {1, true}; }

int main() {
    auto res = fn();
    if (res == 1U) // <-- ERROR
        std::cout << "is one\n";
    else
        std::cout << "is not one\n";
}
```

produces the compiler error

> source:14:23: error: overloaded 'operator==' must have at least one parameter of class or enumeration type
> inline constexpr bool operator==(T lhs, bool rhs) noexcept {

despite the template constraint `requires(false)`.

(Applies to all versions with C++-20 support, including trunk, see godbolt link above.)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVU2P4jgQ_TXhUgIFBwIccmDo6dtqpVavVnMaOUkBnjF21naY6fn1--xkA7Ra2j1sZIxjl-vj1atKbdu36s-z0kzBvSlzomBJXTrNFzaBJJ20raUm27GTwbqseMKgo3U48x036qgaCm8dU5Y_Zfm-sZdaGRmUNZk4UKMldHrmi0-aT8Y6mDozndSVDTXW-OCkMsEvBgXD_AoJx23fcEuBfZg30sOE2J5D6HxW7DPxjHGybW11WFh3wtsv_M7my_a3b_L6JRO7UWGZj2N4FYUyje5bqCsOjQ8tjGfF549OlYVzLC-343xUGhgYyZCkYvRGXpheJzlc65uACHyvA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