Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!brl-adm!adm!chris@mimsy.umd.edu From: chris@mimsy.umd.edu Newsgroups: comp.lang.c Subject: Re: short circuit evaluation Message-ID: <4391@brl-adm.ARPA> Date: Wed, 11-Feb-87 17:12:08 EST Article-I.D.: brl-adm.4391 Posted: Wed Feb 11 17:12:08 1987 Date-Received: Thu, 12-Feb-87 20:09:15 EST Sender: news@brl-adm.ARPA Lines: 44 Dan Hoey writes: > From: Henry Spencer > > I did ask Dennis about [a PDP-11 C compiler short circuiting > multiplies by constant zeroes, thus discarding side effects] > at one point, since strict reading of K&R suggested it was a > bug. His reply, as I recall it, was roughly "I think it is > defensible in principle, but it caused so many complaints that > newer versions of the compiler don't do it". > >Are your cases of justifiable pornography sufficiently specific that >they should appear in the standard? I believe the standard must be >precise here, and the ``so many complaints'' lead me to believe that >the answer must be in favor of guaranteed execution of side-effects. I would prefer to see some guarantee that side effects will occur. Guarantees as to precisely *when* are problematical, and since such have never been made, should not be part of the standard. So let us say that if (*p++ & *q++) and a = *p++ * *q++; and even a = 0 * *p++ * *q++; must always increment both p and q, but not in any particular order, so long as the memory references use the values p and q have before they are incremented. Should we also say that the memory references in the third expression must occur? If not, the compiler can optimise this into p++, q++, a = 0; but if so, must the compiler also do the multiply? (It might overflow, which could be important.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu