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

Reply via email to