() ignored in some expressions

Bjorn Engsig bengsig at oracle.nl
Wed Apr 11 01:23:58 AEST 1990


Article <16414 at haddock.ima.isc.com> by karl at haddock.ima.isc.com (Karl Heuer)
comments why K&R 1 allowed C compilers to rearrange parnthesized expression
as long as it mathematically was the same:
|
|Optimization.  With unsigned integers (and also signed integers in the usual
|implementation), you get exactly the same answer anyway, so why not explicitly
|allow it?
In the university, I did a lot of floating point/numerical programming in 
fortran, and learned by heart that calculation order does matter.  Therefore
I added a bunch of !'s in my K&R 1 when I saw that the C compiler could
rearrange, and I still think it's more a bug than a feature.

Fortunately, this is now gone in ANSI C as you also point out, Karl:
|The places where it's useful are already covered by the as-if rule.
The as if rule could have done better in K&R 1, since it clearly excludes
rearrangning of float calculations, but (normally) not integer.
-- 
Bjorn Engsig,	Domain:		bengsig at oracle.nl, bengsig at oracle.com
		Path:		uunet!mcsun!orcenl!bengsig



More information about the Comp.lang.c mailing list