Subject: Re: cast truncates bits from constant value (8000000000000000 becomes 0)

From: Derek M Jones <[email-masked]>
Date: Fri, 01 Dec 2006 20:49:19 +0000

Linus,

>> One of the gcc maintainers (Andrew Pinski) told me to set it up that
>> way, so I figured it was safe.
> 
> It _is_ safe, as long as you stick to gcc, and as long as you don't mix 
> signs in your values, for example.
> 
> But we actually want to let people compile even the kernel with other 
> compilers than gcc. Most of the time, that means that we strongly 
> encourage those compiler people to support all the gcc extensions (let's 
> face it, standardization is good, and open standards work better than 
> closed ones, and gcc is the most widely spread open and portable compiler 
> BY FAR, so it would be stupid to _not_ do that).

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).

-- 
Derek M. Jones                              tel: +44 (0) 1252 520 667
Knowledge Software Ltd                      mailto:[email-masked]
Applications Standards Conformance Testing    http://www.knosof.co.uk