cast truncates bits from constant value (8000000000000000 becomes 0)
Al Viro
viro at ftp.linux.org.uk
Sat Dec 2 08:00:11 EST 2006
On Fri, Dec 01, 2006 at 08:49:19PM +0000, Derek M Jones wrote:
> The C++ Standard explicitly supports enumeration constants not
> having type int. See sentence 858 of
> http://www.coding-guidelines.com/cbook/cbook1_0b.pdf
> for a discussion of the issues (plus some other sentences).
>
> C compiler vendors, at least those who extend the language, are more
> likely to want to follow the C++ rules (which are documented) than the
> gcc rules (which are poorly documented).
>
> The C++ way of doing things is also likely to be followed by vendors
> whose C compiler is enabled by a command line switch on their C++
> compiler (eg, at least one vendor based in Seattle).
"C++ way of doing things" is hardly an endorsement. _IF_ we are changing
the way enum works, might as well do it sanely and have the type of
enumeration constant same as that of expression initializing it (with
usual implicit initializers). But yes, that explicitly changes semantics -
enum { A = 0L, B, C }; will have A, B and C long, not int. Direct
contradiction with C90/C99...
More information about the Linuxppc-dev
mailing list