I wonder if there are other places where "&" (or "|") is coded and
"&&" (or "||") is meant (or vice-versa) where the result is NOT semantically
the same :-)
It'll take a good checker to sort that one!
Margit
Followup to: <[email protected]>
By author: "J.A. Magallon" <[email protected]>
In newsgroup: linux.dev.kernel
>
> I see a diff:
> - & is bitwise and you always perform the op
> - && is logical and gcc must shortcut it
>
> I think people use & 'cause they prefer the extra argument calculation
> than the branch for the shortcut (AFAIR...)
>
> or not ?
>
In this case it doesn't matter, since gcc should be able to prove the
right-hand-side is side-effect free.
-hpa
--
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
On Fri, 30 May 2003 18:11:49 +0200, [email protected] (Margit Schubert-While) said:
> I wonder if there are other places where "&" (or "|") is coded and
> "&&" (or "||") is meant (or vice-versa) where the result is NOT semantically
> the same :-)
> It'll take a good checker to sort that one!
It shouldn't be hard at all to deal with the form:
(A compare B) op (C compare D)
The scary part would be if the right-hand size has a side-effect - then
the choice of |, & over ||, && would definitely be bug-inducing (or possibly
bug-fixing)?