Consider the following code:
uint32_t foo(uint64_t x ) {
auto y = uint32_t { x };
return y;
}
It is considered a narrowing conversion the compiler feels compelled to warn me about (GCC 9) or even declare an error (clang 9): GodBolt.
My questions:
- Why is
uint32_t { x }
less explicit thanstatic_cast<uint32_t>(x)
? - Why is this more severe with clang than with GCC, meriting an error?