Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: bitwise short-circuiting Message-ID: <1988Feb21.201643.463@utzoo.uucp> Keywords: bitwise optimize open-eyes Organization: U of Toronto Zoology References: <4224@june.cs.washington.edu> Date: Sun, 21-Feb-88 20:16:38 EST 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