Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcs.uucp Path: utzoo!utcs!flaps From: flaps@utcs.uucp (Alan J Rosenthal) Newsgroups: net.lang.c Subject: Re: A simple non-portable expression tha Message-ID: <1229@utcs.uucp> Date: Fri, 9-May-86 04:25:07 EDT Article-I.D.: utcs.1229 Posted: Fri May 9 04:25:07 1986 Date-Received: Fri, 9-May-86 04:40:39 EDT References: <130@brl-smoke.ARPA> <2609@utcsri.UUCP> <972@dataioDataio.UUCP> Reply-To: flaps@utcs.UUCP (Alan J Rosenthal) Organization: University of Toronto Lines: 21 Summary: In article <972@dataioDataio.UUCP> bright@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