Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
240 - (<expression> && <non-zero constant>) always evaluates to Boolean result of <expression>.
Question: Was the bitwise-and operator intended?
This warning indicates that a constant value greater than one was detected on the right side of a logical-AND operation that occurs in a test context.
This expression reduces to a constant value of !!n, which is 0 or 1.
This warning is typically caused by an attempt to mask bits, in which case the operator should be &.
Example
Defective Source
if (x && 3) {;}
Corrected Source
if (x & 3) {;}
Send Feedback on this topic to the authors