Date: Fri, 12 Nov 2021 03:04:43 +0000
The following code is accepted by GCC, Clang and MSVC. I thought it was ill-formed because the variable V0 is not usable in constant expressions. Is this just a bug in all of those compilers? Or is there an explanation in the C++ rules?
struct S { constexpr operator int() const { return 0; } };
void foo(S V0) { constexpr int V1 = V0; }
int main()
{
S V0{};
foo(V0);
}
struct S { constexpr operator int() const { return 0; } };
void foo(S V0) { constexpr int V1 = V0; }
int main()
{
S V0{};
foo(V0);
}
Received on 2021-11-11 21:04:46