https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111808

--- Comment #12 from Aaron Ballman <aaron at aaronballman dot com> ---
(In reply to Joseph S. Myers from comment #11)
> Those aren't integer constant expressions because the floating literals
> aren't the immediate operand of a cast to integer type, so they aren't valid
> constexpr initializers for integer type.

Ah yeah, 6.7.2p6 does make that a constraint. I don't get how this is
particularly helpful to users though; it seems like something you'd expect to
work with only a pedantic warning:

constexpr float f1 = (int)-1.0f; // Okay
constexpr int f2 = (int)-1.0f;   // You are a bad programmer who should feel
bad
constexpr int f3 = -(int)1.0f;   // You guessed the right syntax, congrats!

Reply via email to