A simple non-portable expression tha

bright at dataioDat bright at dataioDat
Tue Apr 29 12:23:00 AEST 1986


In article <2609 at utcsri.UUCP> greg at utcsri.UUCP (Gregory Smith) writes:
>However, I tried this ( using 16-bit short ints for I1,I2 ) on our
>native vax compiler and on our 68K compiler. Both produced identical code
>for (L+I1)+I2 and L+(I1+I2) and L+I1+I2: specifically, ((long)I1+L)+(long)I2.
>I guess the a+b+c is recognized as a special case, and all three are widened
>to a common width regardless of the original associativityy

Shorts in C are always converted to ints before they are used. On the
vax and most 68k compilers, ints are the same as longs. Therefore, this
isn't any 'special case' recognized by the compiler.

Different code for (L+I1)+I2 and L+(I1+I2) will only be generated if
ints are smaller than longs.



More information about the Comp.lang.c mailing list