At 00:45 04/05/2000, Robert M. Love wrote:
> > Rik van Riel wrote:
> > > I'm not that good at C, mas aren't expressions with side-effects
> > > ill-defined? How can we be sure (short of tracking the gcc
> > > mailing lists) that i will be incremented after the left part of
> > > the test?
> > Because it is defined in the C standard?
> > Rik
>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. proof is in K&R, where they
>explicitly mention compiler design or optimization can change compound
>statement ordering in the resulting machine code. thus, i agree an
>alternative should be considered in the kernel.
Sorry, but you are wrong. - Before I sent my previous post I checked K&R
and what you say is true EXCEPT in the cases of &&, ||, ?:, and ','. Proof
K&R, 2nd Ed, Section 2.12 "Precedence and Order of Evaluation" (p.52) and
also check out Section A7.14 "Logical AND Operator" (p.207). In the latter
section, pay special attention to the sentence: "&& guarantees
Maybe you could RTMF before you post...
No offence intended, just correcting factual misinformation.
"Education is what remains after one has forgotten everything he learned in school." - Albert Einstein
-- Anton Altaparmakov Voice: 01223-333541(lab) / 07712-632205(mobile) Christ's College eMail: AntonA@bigfoot.com Cambridge CB2 3BU ICQ: 8561279 United Kingdom WWW: http://www-stu.christs.cam.ac.uk/~aia21/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to firstname.lastname@example.org 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