https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98842
Bug ID: 98842
Summary: optional's spaceship operations generates wrong code
when operator== is not present
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: nunoplopes at sapo dot pt
Target Milestone: ---
struct expr {
std::strong_ordering operator<=>(const expr &rhs) const;
//bool operator==(const expr &rhs) const;
};
int f() {
return std::is_eq(std::optional<expr>() <=> std::optional<expr>());
//return std::optional<expr>() == std::optional<expr>();
}
Function f() is compiled to 0 like that. But if you uncomment the
expr::operator== line, it returns 1.
https://gcc.godbolt.org/z/fv85eP