Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: short circuit evaluation & side-effects Message-ID: <7634@utzoo.UUCP> Date: Fri, 6-Feb-87 13:05:03 EST Article-I.D.: utzoo.7634 Posted: Fri Feb 6 13:05:03 1987 Date-Received: Fri, 6-Feb-87 13:05:03 EST References: <425@bobkat.UUCP> <102600001@datacube> <7610@utzoo.UUCP>, <107@tmsoft.UUCP> Organization: U of Toronto Zoology Lines: 17 > As I understand it this means the results of: > (1) x = *i++ * (1 - *i++); > is unpredicatable. ANSI added the unary + to fix this (as well as for > numerical analysis (i.e. floating point) calculations) so that: > (2) x = +(*i++ * (1 - *i++)); > does what one would expect... Hold it, you are attributing incorrect properties to unary +. It does nothing of the kind. The sole and only relevant property of unary + is that it inhibits regrouping of expressions, e.g. "a + +(b + c)" is guaranteed to add b and c and then add the result to a, whereas "a+(b+c)" might add a to c and then add the result to b. Unary + does *not* define a "sequence point" and hence does not promise anything about the timing of side effects. -- Legalize Henry Spencer @ U of Toronto Zoology freedom! {allegra,ihnp4,decvax,pyramid}!utzoo!henry