https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94061

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Frank Heckenbach from comment #1)
> I ran into the same problem.
> 
> Interestingly, clang also seems to reject it, so maybe it is wrong by the
> letter of the standard? Though it would seem strange to me -- after all,
> when manually implementing B::operator<=> a protected operator in A will do
> fine.

How do you define it?  It works if we define it as

  auto operator <=> (const B& b) const {
    return A::operator<=>(b);
  }

but not if it's defined as

  auto operator <=> (const B& b) const {
    return static_cast<const A&>(*this) <=> static_cast<const A&>(b);
  }

According to [class.spaceship], IIUC the synthesized operator<=> looks more
similar to the latter invalid definition (invoking <=> recursively as an
operator expression on each pair of corresponding subobjects), so GCC/Clang
might be right to define it as deleted.

Reply via email to