<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62427>62427</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Failures inside defaulted comparison operator bodies are considered SFINAE
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ilya-biryukov
</td>
</tr>
</table>
<pre>
But only if the body is actually being generated on that particular use.
E.g. in the following program the result of a concept evaluation changes depending on whether the defaulted body was generated during the evaluation or not:
```cpp
struct MyBool {};
struct X {
friend MyBool operator == (X, X);
};
struct Z {
X a;
friend bool operator ==(Z, Z) = default;
};
template <class T>
concept IsComparable = requires { T() == T(); };
template <class T>
concept IsComparable2 = requires { T() == T(); };
void test() {
IsComparable<Z>; // force generation for body of 'operator ==' without
// Static assertion succeed if the previous line is uncommented and fails if it's commented.
static_assert(IsComparable2<Z>);
}
```
[godbolt](https://gcc.godbolt.org/z/xYe4sqxqo)
Note that MSVC and GCC mark the operator as deleted, this does not seem standard-compliant. They probably still miss the changes from [p2002r1](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2002r1.html), in particular changes to [(class.eq)p2](https://eel.is/c++draft/class.eq#2) that ask to check for "usable candidates" instead of checking for "valid expressions".
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU-P27gP_TTKhRjDlvPHPuTQZJofemgvLX6YnctCluhYHVnyiHLS7Kdf0HGmabe7wC4QJJFEvkdSj5QiskePuBWrnVg9LtSYuhC31l3UQ2PjZXwJp0UTzGW7GxME7y5gW0gdAm-CJVA6jcq5CzRo_RGO6DGqhAaCh9SpBIOKyerRqQgjYSbyR5G_e58dM7B-QmqDc-HMzkMMx6j6aTcijS5BaEGBDl7jkABPyo0q2eBBd8ofkcDggN6wc_Bw7jB1GCd_g60aHQcyRXpWdBebGSO7sN0dZojgQxLlu2uMYp1fP3oYrjuU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