Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!floyd!harpo!decvax!cca!ima!ism780!darryl From: darryl@ism780.UUCP Newsgroups: net.lang.c Subject: Re: What should a C compiler do? - (nf) Message-ID: <118@ism780.UUCP> Date: Wed, 28-Mar-84 23:49:03 EST Article-I.D.: ism780.118 Posted: Wed Mar 28 23:49:03 1984 Date-Received: Fri, 30-Mar-84 02:12:42 EST Lines: 23 #R:mprvaxa:-50100:ism780:12500001:000:887 ism780!darryl Mar 27 16:03:00 1984 Very clearly #1 is wrong. K&R says "The usual arithmetic conversion is peformed on the expression, but the result must be int." I don't find anything disturbing about #2 at all. The result of b++ is the original value of b. After it has been used in computing the expression, it is incremented. Several places in K&R mention that the only way to specify evaluation order in an expression is to write several expressions, assigning results to temps. In fact, the reason that you get different code is easily explained: normally the actual increment is put off until after evaluation of the expression is complete -- this is what you get for "a = b++ + b;". But since the result of the expression "if( a = b++ + b ) ;" might result in a branch before the end of the statement, the increment is done right after b is fetched, the first time. Darryl Richman ...!ima!ism780!darryl