i is `the left operand'. If foo() returns 0, i becomes 0. 0 is `the value
stored in the left operand'. Thus the value of the assignment is 0. 0 is a
false value, so if(i=foo()) { bar(); } will not call bar. What part of this
are you not getting?
>
>Even 'gcc' knows that the operation is incorrect, but you have to
>turn on -Wall.
>
>xxx.c: In function `main':
>xxx.c:13: warning: suggest parentheses around assignment used as truth value
gcc knows that mistyping = for == is a common mistake. It tries to guess when
you have made that mistake, and warns you about it. But the extra parentheses
do not make the code correct when it wasn't before. They are only a hint to
gcc that you don't want to see the warning. The actual meaning of the code is
unchanged.
-- Alan Curry- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/