[PATCH, v5] c++: Fix up synthetization of defaulted comparison operators on classes with bitfields [PR102490]
Jakub Jelinek
jakub@redhat.com
Wed Oct 6 09:06:40 GMT 2021
On Tue, Oct 05, 2021 at 10:40:45PM -0400, Jason Merrill wrote:
> I've switched to handling bases via binfo as discussed on IRC and added
> spaceship-synth14.C to test proper base handling with virtual <=>. Here's
> what I'm committing:
Thanks a lot.
I see spaceship-synth8.C is accepted without errors (| LOOKUP_NONVIRTUAL |
LOOKUP_DEFAULTED didn't help it for me back when playing with it), but if I add
E e1, e2;
auto x = e1 <=> e2;
at the end of it, it is rejected:
spaceship-synth8.C:26:17: error: use of deleted function ‘virtual constexpr std::strong_ordering E::operator<=>(const E&) const’
26 | auto x = e1 <=> e2;
| ^~
spaceship-synth8.C:22:24: note: ‘virtual constexpr std::strong_ordering E::operator<=>(const E&) const’ is implicitly deleted because the default definition would be ill-formed:
22 | std::strong_ordering operator<=>(const E&) const override = default;
| ^~~~~~~~
spaceship-synth8.C:21:8: error: no match for ‘operator<=>’ (operand types are ‘const D’ and ‘const D’)
21 | struct E : D {
| ^
spaceship-synth8.C:19:32: note: candidate: ‘virtual std::strong_ordering D::operator<=>(const E&) const’ (reversed)
19 | virtual std::strong_ordering operator<=>(const struct E&) const = 0;
| ^~~~~~~~
spaceship-synth8.C:19:44: note: no known conversion for argument 1 from ‘const D’ to ‘const E&’
19 | virtual std::strong_ordering operator<=>(const struct E&) const = 0;
| ^~~~~~~~~~~~~~~
Is that ok (i.e. whether it is accepted or rejected when the operator<=>
is actually not called falls into "no diagnostics required" category)?
Note, before this fix we were accepting it even with those
E e1, e2;
auto x = e1 <=> e2;
lines in there. Perhaps we want to copy spaceship-synth8.C to another
test that will add those two lines and check for the errors...
Jakub
More information about the Gcc-patches
mailing list