Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: () ignored in some expressions Message-ID: <1990Apr14.235432.6340@utzoo.uucp> Organization: U of Toronto Zoology References: <48079@lanl.gov> <16414@haddock.ima.isc.com> <1990Apr10.181833.5453@utzoo.uucp> <819@s6.Morgan.COM> Date: Sat, 14 Apr 90 23:54:32 GMT In article <819@s6.Morgan.COM> amull@Morgan.COM (Andrew P. Mullhaupt) writes: >> ... only associative and commutative operators were >> covered by the old rule, and subtraction is neither. > >Well what you say is true, but his example is still important when >recast into the form: > > Big * (Big + x) The "*" operator neither associates nor commutes with "+", so this is *still* irrelevant to the discussion at hand. Some compilers will try to use the *distributive* property to optimize this expression, but that has always been an optimization that would -- if integer overflow produces noticeable effects, rare in old compilers -- break the rules. There has never been a rule allowing the compiler to use distributivity in the way that use of associativity and commutativity was explicitly allowed. >It is quite important to have this sorted out by compile time, since >run time checks on all integer arithmetic are very expensive. This depends on the machine and the compiler. On some it's essentially free. -- With features like this, | Henry Spencer at U of Toronto Zoology who needs bugs? | uunet!attcan!utzoo!henry henry@zoo.toronto.edu