Re: C and side-effects

From: Ben Pfaff (pfaffben@msu.edu)
Date: Wed May 03 2000 - 20:25:14 EST


"Robert M. Love" <rml@tech9.net> writes:

> maybe im reading the thread wrong, but Cesar is saying the code
> while ((mm->swap_cnt << 2 * (i + 1) < max_cnt) && i++ < 10)
> does not guarentee that the expression to the left of && occurs prior to
> "i++" -- and he is Right,
> because the C standard does *not* specify this.

Yes, it does specify this. The C89 standard says, in section
6.3.13, the following:

| [T]he && operator guarantees left-to-right evaluation: there is
| a sequence point after the evaulation of the first operand. If
| the first operand compares equal to 0, the second operand is
| not evaluated.

> proof is in K&R, [...]

K&R does not define the C language.

-
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/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:13 EST