[Bug c++/95567] Defaulted virtual <=> has the wrong behavior
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jun 9 14:52:25 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95567
--- Comment #1 from Barry Revzin <barry.revzin at gmail dot com> ---
To follow up on this, it's not the operator<=> being virtual that's significant
but rather the class itself being polymorphic. This exhibits the same behavior:
#include <compare>
struct B {
B(int i) : i(i) {}
VIRTUAL ~B() = default;
std::strong_ordering operator<=>(B const& other) const = default;
int i;
};
struct D : B {
D(int i, int j) : B(i), j(j) {}
int j;
};
bool check() {
return B(2) == D(2, 3);
}
https://godbolt.org/z/ZFqB59
More information about the Gcc-bugs
mailing list