https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94061
Bug ID: 94061 Summary: defaulted member operator <=> defined as deleted if a base has protected member operator <=> Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: okannen at gmail dot com Target Milestone: --- Version: GCC 10.0.1 20200229 When a base class declares the three way comparison member operator as protected, a defaulted three way comparison member operator in the derived is defined as deleted, while it shall obviously not: Code: #include <compare> struct A{ protected: auto operator <=> (const A&) const = default; }; struct B : A { auto operator <=> (const B&) const = default; }; void f(B b){ b <=> b; //error see bellow } Error message: <source>: In function 'void f(B)': <source>:15:11: error: use of deleted function 'constexpr auto B::operator<=>(const B&) const' 15 | b <=> b; | ^ <source>:11:10: note: 'constexpr auto B::operator<=>(const B&) const' is implicitly deleted because the default definition would be ill-formed: 11 | auto operator <=> (const B&) const = default; | ^~~~~~~~ <source>:11:10: error: 'auto A::operator<=>(const A&) const' is protected within this context <source>:5:10: note: declared protected here 5 | auto operator <=> (const A&) const = default; | ^~~~~~~~ Compiler returned: 1