V10/cmd/f2c/honorp

From alice!dmr Wed Apr 11 09:08:05 EDT 1990

honorp (dmr) Wed Apr 11 01:46:18 1990

   There is confusion about the rearrangement rules in the K&R 1
   language and about how ANSI C changed things.  The wording in K&R 1
   wasn't precise enough in any event, but there was also a real
   change in content.

   K&R 1 said, "Expressions involving a commutative and associative
   operator (*, +, |, ^) may be rearranged arbitrarily, even in
   the parentheses; to enforce a particular order of evaluation
   an explicit temporary must be used."

   The exact intent of this statement was no more than this:
   "A compiler is entitled to regard mathematically commutative
   and associative operators as computationally commutative and
   associative."

   The imprecision of the original statement caused considerable worry,
   which still persists; for example it could be interpreted as saying that
	   along+ashort+ashort
   or even
	   (along+ashort)+ashort
   might add the shorts in short precision before adding the sum to the long.
   This wasn't the intent, and I don't think it's the practice.

   X3J11 decided not only to clarify the matter, but also to
   strengthen the requirements.  Its rule is that the value
   of an expression must be computed as if each subexpression
   in the parse (including the effects of parentheses) were computed
   as written. The temporal order of side effects remains undefined.