This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

2.95.2 preprocessing phase calculations (C, not C++)


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]