On 11/06/2010 02:37 PM, Gabriel Dos Reis wrote:
static const unsigned x = (unsigned)-1;
enum e {
ey = (int)x
};
The compiler is right: the value of `x' cannot fit in an int, therefore the
declaration is ill-formed. This has nothing to do with constexpr.
It does have to do with the definition of a constant expression, though.
4.7 says, "If the destination type is signed, the value is unchanged if
it can be represented in the destination type (and bit-field width);
otherwise, the value is implementation-defined."
That suggests to me that (int)x is a constant expression with
implementation-defined value, and g++ is wrong.
Jason