bitwise short-circuiting
Henry Spencer
henry at utzoo.uucp
Mon Feb 22 11:16:38 AEST 1988
I talked to Dennis some years ago about a related issue: should it be
permissible to optimize "0 * a()" to "0"? The V7 compiler did this,
although the C Reference Manual seemed to imply that it shouldn't. As
I recall (it's been a while...), Dennis replied roughly "the optimization
seemed reasonable to me, but I got so much flak about it that I finally
took it out". The current X3J11 draft says likewise: the side effects
must happen, even if the compiler doesn't use the value of the function.
In practice, there are so many sleazy programmers out there that the only
way you can get away with short-circuiting something like this is if the
language spec explicitly permits it from the beginning. Bliss did that.
--
Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry
More information about the Comp.lang.c
mailing list