https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116311
Bug ID: 116311
Summary: GCC accepts invalid program with conversion function
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
The following program is accepted by gcc and prints 1 while clang and msvc
rejects it. https://godbolt.org/z/MG3os6h7v
```
#include <iostream>
struct A {
int i = 0;
constexpr operator int&() { return i; }
};
struct B {
A a;
constexpr bool operator==(const B &) const = default;
};
constexpr bool f() {
constexpr B x;
return x == x;
}
int main()
{
std::cout << f();
}
```