https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103947
Bug ID: 103947 Summary: wishlist: warning if explicitly defaulted (spaceship) operator is deleted Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenb...@fh-soft.de Target Milestone: --- % cat test.cpp #include <compare> struct A { }; struct B: A { auto operator <=> (const B &) const = default; }; int main () { B () == B (); } % g++ -std=c++20 -Wall -Wextra test.cpp test.cpp:7:8: note: 'constexpr bool B::operator==(const B&) const' is implicitly deleted because the default definition would be ill-formed: [...] This error is correct, of course. When commenting out the statement in main, though, the program compiles without a warning. I think a warning would be useful here, since the programmer explicitly declared the defaulted operator, so they wouldn't expect it to be deleted. In my actual use case, I did get the error where the code tried to use the operator, but that was (a) far removed from that declaration and (b) buried in lots of "candidate" notes (as is common, especially with commonly used operators), so I actually had to grep through the compiler output to find the place where it explained why this (intended) candidate was deleted. A warning right at the declaration would have made it much easier to find.