This program
```
struct A {
int i = 0;
constexpr operator int() const { return i; }
constexpr operator int&() { return ++i; }
};
struct B : A {
bool operator==(const B &) const = default;
};
constexpr bool f() {
B x;
return x == x;
}
static_assert( f() ); // fails in Clang
```
is accepted by GCC and MSVC, but fails static assertion in Clang. Online demo: https://gcc.godbolt.org/z/5hYob3K66
Clang looks wrong here, because not-const `operator int&` should not be called from within `B::operator==(const B &) const`.
Related discussion: https://stackoverflow.com/q/78850335/7325599
This program
is accepted by GCC and MSVC, but fails static assertion in Clang. Online demo: https://gcc.godbolt.org/z/5hYob3K66
Clang looks wrong here, because not-const
operator int&
should not be called from withinB::operator==(const B &) const
.Related discussion: https://stackoverflow.com/q/78850335/7325599