<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Defaulted comparison operator with built-in type as member in same namespace as comparison operator template rejected"
   href="https://bugs.llvm.org/show_bug.cgi?id=44721">44721</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Defaulted comparison operator with built-in type as member in same namespace as comparison operator template rejected
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david@doublewise.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following well-formed code:

```
namespace n {

template<typename T>
bool operator==(T const &, T const &) {
    return true;
}

struct s {
        friend bool operator==(s const &, s const &) = default;
        int x;
};

}
```

is rejected by clang with the following message:

```
main.cpp:4:6: error: overloaded 'operator==' must have at least one parameter
of class or enumeration type
bool operator==(T const &, T const &) {
     ^
main.cpp:9:14: note: in instantiation of function template specialization
'n::operator==<int>' requested here
        friend bool operator==(s const &, s const &) = default;
                    ^
1 error generated.
```

A similar error occurs for `operator<=>`. This occurs only when the comparison
operator is defaulted. Manually writing out the equivalent definition is fine.


(In the real code, the generic `operator==` is constrained with a concept that
would not match any built-in type)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>