[Bug c++/102407] New: Ambiguity is not reported in case of separate inheritance of `<` and `<=>` operators
fchelnokov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 20 08:55:18 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102407
Bug ID: 102407
Summary: Ambiguity is not reported in case of separate
inheritance of `<` and `<=>` operators
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following code is ill-formed:
```
#include <compare>
struct A {
bool operator <(const A&) const { return true; }
};
struct B {
auto operator <=>(const B&) const = default;
};
struct C : A, B {};
int main() {
C c;
c.operator<(c);
return c < c;
}
```
and it shall be rejected due to ambiguity, but it not in GCC (neither in other
compilers). Demo: https://gcc.godbolt.org/z/d6G7e9319
The detailed explanation why is here:
https://stackoverflow.com/questions/69240507/ambiguity-in-case-of-multiple-inheritance-and-spaceship-operator-in-c20/69245639#69245639
More information about the Gcc-bugs
mailing list