Re: [C++0x] code that used to be accepted isn't accepted anymore (related to constexpr changes?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux