conditional expression evaluation question
Mark Nagel
cccmark at ucdavis.UUCP
Wed Jan 14 03:34:23 AEST 1987
The original question regarded the evaluation of a bitwise or expression
which would *always* be fully evaluated. C only guarantees that logical
expressions will be short circuited. There may be a problem with your
expression though in other ways. C does not guarantee that an expression
with side effects will be executed in any special order. Therefore, the
original expression:
if (*cp++ | *cp++ | *cp++ == 0) {
...
}
will evaluate each *cp++ eventually, but I do not believe you can assume
the result will be the same as (*cp | *(cp+1) | *(cp+2)) followed by
cp += 3 on all machines.
- Mark Nagel
ucdavis!deneb!cccmark at ucbvax.berkeley.edu (ARPA)
mdnagel at ucdavis (BITNET)
...!{sdcsvax|lll-crg|ucbvax}!ucdavis!deneb!cccmark (UUCP)
More information about the Comp.lang.c
mailing list