https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97121
Bug ID: 97121 Summary: ICE (segfault) on incorrect default three-way comparison declaration Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: warp at iki dot fi Target Milestone: --- Consider the following code (which mistakenly tries to return 'bool' from the three-way comparison rather than 'auto'): //---------------------------------------------------------- #include <compare> class MyClass { int mValue; public: MyClass(int value): mValue(value) {} bool operator<=>(const MyClass&) const = default; }; int main() { MyClass a = 10, b = 15; return (a < b); } //---------------------------------------------------------- Trying to compile it causes a segfault: ------------------------------------------------------------ test.cc: In member function ‘constexpr bool MyClass::operator<=>(const MyClass&) const’: test.cc:11:10: internal compiler error: Segmentation fault 11 | bool operator<=>(const MyClass&) const = default; | ^~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. ------------------------------------------------------------ The correct version (ie. with an 'auto' return value) compiles successfully.