https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063
Bug ID: 113063 Summary: Strange linker error in special case involving local class with defaulted spaceship operator and static assert Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kristian.spangsege at gmail dot com Target Milestone: --- With the latest GCC (13.2) and also with GCC 11.4, the following C++ code triggers a strange linker error: #include <compare> int main() { struct X { auto operator<=>(const X&) const = default; }; X x; static_assert(noexcept(x < x)); static_cast<void>(x < x); } Godbolt: https://godbolt.org/z/PfPfznT6Y The linker error is this: /usr/bin/ld: /tmp/ccsnSU59.o: in function `main::X::operator<=>(X const&) const': t.cpp:(.text+0x31): undefined reference to `std::strong_ordering::strong_ordering(std::strong_ordering const&)' It seems to be a bug that is triggered by the presence of the static assertion, but only when the it occurs before the actual invocation of the less-than comparison operation. Also, if the local class (`X`) is moved out of `main()`, the problem goes away.