2.95.2 preprocessing phase calculations (C, not C++)
Dave Brolley
brolley@redhat.com
Thu Feb 10 15:22:00 GMT 2000
The preprocessor must use arithmetic that has "at least the
ranges" specified by in the section referenced by
lib.support.limits. i.e. these ranges may be exceeded.
Dave
Joseph Rivilis wrote:
>
> I use djgpp 2.95.2 1999102, with .c input file.
>
> Command line options were '-ansi -pedantic', but I think
> following is relevant not only for ANSI subcase.
>
> It is natural for one to expect (with '-ansi -pedantic' it is a
> must) that preprocessor calculations needed by (acceptable)
> constant expression are the same as they were for this constant
> expression after preprocessing phase (if it is acceptable there
> too).
>
> For ANSI C it is must because standard simply refers in both
> theese cases to run-time expression evaluation rules, so
> whatever the rules are, they are same.
>
> GCC for x86 seems to perform preprocessor phase calculations
> as 64 -bit for constants of (unsigned) int and long types even
> though int and long are 32 bit wide for the program being
> compiled.
>
> Below are two constant expressions which demonstrate difference
> between preprocessing phase evaluation and the normal one:
>
> #if ( ((3U<<31) >> 31) == 3 ) is true for GCC
> if ( ((3U<<31) >> 31) == 1 ) is true for GCC
> #if ( ((3 <<31) >> 31) == 3 ) is true for GCC
> if ( ((3 <<31) >> 31) == -1 ) is true for GCC
>
> Sincerely yours,
> Joseph Rivilis
More information about the Gcc-bugs
mailing list