New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[class.compare.default] p1 The condition of implicitly defining a defaulted comparison operator function CWG2546 #5336
Comments
So even if the implicit exception specification is not needed, IIUC this is a bug of clang. Please report it here. |
No, the defaulted function is not deleted. |
Are you explaining why the comment in [class.compare.secondary] p3 is wrong? I believe it's right, extremely. When the rewritten candidate is found, a nested overload resolution is performed for the written expression and then fails. According to [over.match.general] p4, the rewritten candidate is not usable. |
"the rewritten candidate is not usable" No, it is usable. First,
IMO, overload resolution only considers the candidate itself. It shouldn't consider subsequent interpretation for the expression. The clue is here:
That is, only after the overload resolution for the expression
It didn't say the reinterpretation of [over.match.general] p1 states that
For expression |
If the comment is the intent of [class.compare.secondary] p2, it may be improved to
the candidate selected by overload resolution for |
Another example that can prove we shouldn't augment the extent of considering overload resolution for this definition is: struct HasNoLessThan {
operator int(){
return 0;
}
};
struct C{
friend HasNoLessThan operator <=>(C const&, C const&);
bool operator <(C const&) const = default;
};
int main(){
using ptr = decltype(&C::operator<);
} Both implementations accept this example. The nested overload resolution will be performed for the operator |
The "selected candidate" in [class.compare.secondary] p2 is The fixes in CWG2546 should address this, too. |
[class.compare.default] p1 just says
Consider this example
Since
&C::operator<
appears as an unevaluated operand, functionC::operator <
is not odr-used by this expression. However, Clang reports a diagnosis that:[except.spec] p11 says
So, It is reasonable to check the definition of the defaulted function. However, we just define two contexts that can cause the implicit definition for the defaulted function. Checking the expressions in the implicit definition is not defined to be odr-used nor constant evaluation of the function. It seems that we lack the case that determines the exception specification of a defaulted comparison operator function.
Improvement:
The text was updated successfully, but these errors were encountered: