Standards compliant preprocessor arithmetic
Neil Booth
neil@daikokuya.demon.co.uk
Sun May 26 23:32:00 GMT 2002
Geoff Keating wrote:-
> I think I should quote the relevant parts of the standards, just so
> we know what we're talking about. 6.8.1 of C89 reads:
>
> ... the controlling constant expression ... is evaluated according to
> the rules of 6.4 using arithmetic that has at least the ranges
> specified in 5.2.4.2, except that *int* and *unsigned int* act as if
> they have the same representation as, respectively, *long* and
> *unsigned long*.
>
> The wording in c99 is in 6.10.1, and reads:
>
> ... the controlling constant expression ... is evaluated according to
> the rules of 6.6 except that all signed integer types and all unsigned
> integer types act as if they have the same representation as,
> respectively, the types *intmax_t* and *uintmax_t* defined in the
> header *<stdint.h>*.
>
> The c99 semantics are compliant with the c89 semantics, because of the
> 'at least'. I'd recommend that we allow the c89 cpp to perform
> arithmetic to the size of at least the target's "long long".
I have the C++ standard and it's the same as c89. However, I disagree
that they're the same: C89 says int should have the representation
of long. C99 says it should have the representation of intmax_t.
I'm not immediately sure how this could affect arithmetic, but it sounds
like it could.
Neil.
More information about the Gcc-patches
mailing list