https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96299
Bug ID: 96299 Summary: Defaulted operator <=> implicitly deleted when a member has operator < and operator == and return type is specified Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc-bugzilla at mysko dot org Target Milestone: --- The following sample fails to compile with GCC 10.1 and with trunk as of 2020-07-22. =================== #include <compare> struct Legacy { bool operator==(Legacy const&) const; bool operator<(Legacy const&) const; }; struct A { std::strong_ordering operator <=> (A const& other) const = default; Legacy l; }; int main() { A a, b; return a < b; } =================== With the following error: <source>: In function 'int main()': <source>:19:14: error: use of deleted function 'constexpr std::strong_ordering A::operator<=>(const A&) const' 19 | return a < b; | ^ <source>:11:24: note: 'constexpr std::strong_ordering A::operator<=>(const A&) const' is implicitly deleted because the default definition would be ill-formed: 11 | std::strong_ordering operator <=> (A const& other) const = default; | ^~~~~~~~ <source>:11:24: error: no match for 'operator<=>' (operand types are 'Legacy' and 'Legacy') >From my understanding of p1186r3 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1186r3.html) the code should be accepted. The GCC standards support table lists p1186r3 as implemented in GCC 10. According to p1186r3, the defaulted operator <=> should use the member's < and == operators if the return type is specified (strong/weak/partial), and should not require a <=> operator for the member.