A simple non-portable expression tha
    Alan J Rosenthal 
    flaps at utcs.uucp
       
    Fri May  9 18:25:07 AEST 1986
    
    
  
In article <972 at dataioDataio.UUCP> bright at dataio.UUCP (Walter Bright) writes:
>Different code for (L+I1)+I2 and L+(I1+I2) will only be generated if
>ints are smaller than longs.
This is strictly true, but it is not true that different code for (L+I1)+I2
and L+(I1+I2) will necessarily be generated if ints are smaller than longs.
(Besides which, it is unwise to assume this; see K&R p34...)
Anyway, the official K&R quote here is from page 185 which says:
	...[besides precedence rules] the order of evaluation of
	expressions is undefined.  ... Expressions involving a
	commutative and associative operator (*, +, &, |, ^) may
	be rearranged arbitrarily, even in the presence of parentheses;
	to force a particular order of evaluation an explicit
	temporary must be used.
So you see that the expressions (L+I1)+I2 and L+(I1+I2) are not necessarily
distinct (though not necessarily identical either).
Alan J Rosenthal
{linus|decvax}!utzoo!utcs!flaps, {ihnp4|allegra}!cbosgd!utcs!flaps
    
    
More information about the Comp.lang.c
mailing list