chip@t4test.UUCP (Chip Rosenthal) (04/03/84)
> From: keashly@mprvaxa.UUCP (Lance Keashly) > > m(){ > int a,b,c; > { > /* case 2 ideally "a" should have the same value after but pcc > interprets them differently (K&R say that it is OK 185) */ > if ( a = b++ + b ); > a = b++ + b; > } Anybody want to handle a question I have about the above? It has never been clear to me what an expression like "a = b++ + b" evaluates to, i.e. would the right-hand addend be the value before or after the incrementation? Is the answer to this compiler/machine dependant? (Mailing a response is probably preferable to posting.) Thanks. Chip Rosenthal, Intel/Santa Clara {pur-ee,hplabs,ucbvax!amd70,ogcvax!omsvax}!intelca!t4test!chip
robert@erix.UUCP (Robert Virding) (04/06/84)
If I remember rightly K&R explicitly state (I can't remember page and chapter) that the order of evaluation of an expression is undefined. In a = b++ + b; the result depends on which order the rhs is executed. Therefore it isn't neccessary that an expression of this type to generate the same result in different situations. Robert Virding @ L M Ericsson, Stockholm