Evaluation of if's
Steve Summit
scs at adam.mit.edu
Wed Jun 5 09:39:28 AEST 1991
In article <FPB.91Jun4174400 at ittc.ittc.wec.com> fpb at ittc.wec.com (Frank P. Bresz) writes:
> if ( (i=1) == (i=2) )
>
>Is somebody wrong or is the behavior undefined?
>Personal opinion: I think the behaviour is undefined by K&R anyway I can't
>say for ANSI.
Of course it's undefined. (It contains two side effects not
separated by a sequence point.) Given that the behavior is
undefined, I'd say it's fairly pointless to catalog the behavior
of available compilers. As Kernighan and Ritchie point out, and
I am fond of quoting, "if you don't know how they are done on
various machines, that innocence may help to protect you."
The comp.lang.c frequently-asked questions list has a bit to say
about undefined order of evaluation. Did you check it first?
Steve Summit
scs at adam.mit.edu
More information about the Comp.lang.c
mailing list