<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64124>64124</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang falsely instantiates an object of a type with defaulted `operator==` despite its `requires false`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AMP999
</td>
</tr>
</table>
<pre>
According to a discussion on [cpplang.slack.com](https://cpplang.slack.com/archives/C6K47F8TT/p1689107603335019?thread_ts=1689107603.335019&cid=C6K47F8TT) , apparently, there is a bug in clang which causes the "PROBLEM" code (using `=default`) to be instantiated, despite its `requires false`.
> arthur-odwyer(@Quuxplusone):
> (attn
> [@Nikolas Klauser](https://cpplang.slack.com/team/U02TVB7TMK2)
> )
> Where would we have to modify in the standard to get this to work as intended?
> https://godbolt.org/z/nc4Kv3TT6
> template<class T>
> struct S {
> Holder<T> h;
>
> #if PROBLEM
> friend bool operator==(const S& s, const S& t)
> requires false = default;
> #else // NO PROBLEM
> friend bool operator==(const S& s, const S& t)
> requires false { return s.h == t.h; }
> #endif
> };
> The "NO PROBLEM" code is quite properly never instantiated for any T, because it requires false; but the "PROBLEM" code (using =default) is instantiated, despite its requires false. Why does this happen, and can we make it not happen?
> Brian Bi:
> I think that might be a bug in Clang. [temp.inst]/5 says that a friend function definition isn't supposed to be instantiated until "it is referenced in a context that requires a function definition to exist or if the existence of the definition affects the semantics of the program".
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU-T4rYT_TTi0rWUkcDgA4dhWOr3q8n-SZZkjylZamNlhOSV2sOQT59qMwww2crmEheFLbWkfv3Ur1vn7HYBcSlmKzFbj3RPbUzLuw-fq6oa1dEel3fGxGRd2AFF0GBdNn3OLgaIAcRsZbrO67AbZ6_N49jEvZithVy0RF0W6k7IjZCbvy-SG51M654wC7m5Lx-m881iuxVy003KRTUp5mWhlJ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