This patch just makes the error message clearer by reinforcing the cause
was a lack of viable three-way comparison function for the
complete object.
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential D97990
[clang] Improve diagnostics on implicitly deleted defaulted comparisons mizvekov on Mar 4 2021, 4:30 PM. Authored by
Details This patch just makes the error message clearer by reinforcing the cause Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Diff Detail
Unit Tests Event TimelineComment Actions I don't think this change is right: for struct A { int &r; bool operator==(const A&) const = default; }; we should warn about the reference member (as we do), but for struct A { int &r; bool operator<(const A&) const = default; }; ... we shouldn't recurse to subobjects because they make no difference. The problem in that example is that there's no operator<=> for A; the fact that there's a reference member is irrelevant. I think it would be useful to change the diagnostic from <stdin>:3:8: warning: explicitly defaulted relational comparison operator is implicitly deleted [-Wdefaulted-function-deleted] bool operator<(const A &) const = default; ^ <stdin>:3:8: note: defaulted 'operator<' is implicitly deleted because there is no viable comparison function to something more verbose, such as <stdin>:3:8: warning: explicitly defaulted relational comparison operator is implicitly deleted [-Wdefaulted-function-deleted] bool operator<(const A &) const = default; ^ <stdin>:3:8: note: defaulted 'operator<' is implicitly deleted because there is no viable three-way comparison function for 'A' Comment Actions You are absolutely right, my bad!! So we stealth fix this revision to improve the message :D Comment Actions Change to simpler way to do it:
|