Re: Kernel bugs found using inspect tool

From: Jeffrey B. Siegal (jbs@quiotix.com)
Date: Tue Feb 29 2000 - 03:21:56 EST


Ben Kosse wrote:
>
> > nathan.zook@amd.com wrote:
> > > > if((a == b) | (c == d) | (e < f))
> > If c, d, e and f are simple variables, then the compiler should be able to
> > tell that it makes no difference whatsoever whether | or || is used, and
> > should generate the same (fastest) code for both.
>
> Not necessarily true. || has the side effect of allowing you to jump out after
> the first comparison. | *REQUIRES* you do all comparisons.

Reread carefully. If "c, d, e, and f are simple variables" then the
expression in question can not have side effects, and it makes no difference
whether all the comparisons are performed or not (nor what in order they are
performed).

-
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 : Tue Feb 29 2000 - 21:00:21 EST