Evaluation of if's
Sudheer Apte
sa1z+ at andrew.cmu.edu
Sat Jun 15 02:28:36 AEST 1991
pgheit01 at ulkyvx.bitnet writes:
>
> [...] AAAAAARRRRRGGGGHHHHH! [...]
>
> The statement if ((i = 1) == (i = 2)) is valid. ANSI C evaluates
> conditions from left to right. *ALWAYS* ANSI C short-circuits a
> conditional statement *ALWAYS* (unless you tell it not to)
Hmm. Since you'll probably be flamed out of existence for this, I
won't bother. (In case you haven't yet figured it out, '==' is not
guaranteed anywhere to evaluate left-to-right. Your second example
[deleted] doesn't use '==', and is correct.)
I just have a suggestion to make to Steve Summit: do you think this
is a good question to put in the FAQ? I vote to put it in.
Thanks,
Sudheer.
----------------
...{harvard, uunet}!andrew.cmu.edu!sa1z
sa1z%andrew.cmu.edu at CARNEGIE
More information about the Comp.lang.c
mailing list