[previous] 4106 [next] Both operands of && operator are arithmetic or bitwise expressions.
Arithmetic type - Operands REFERENCE - ISO:C90-6.3.13 Logical AND Operator

The two operands of this logical AND operator (&&) are derived from bitwise or arithmetic operators. This is probably a mistake; perhaps the bitwise AND operator (&) was intended ?

For example:


/*PRQA S 2017,3198,3199,3203,3227,3408 ++*/

extern void foo(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
{
    int r;

    r = (a < b) && (c < d);                     /* OK */
    r = (a == b) && (c == d);                   /* OK */

    r = (a + b) && (c + d);                     /* Message 4106 */
    r = (a ^ b) && (c ^ d);                     /* Message 4106 */

    r = (a + b) && (c < d);                     /* Message 4108 */
    r = (a > b) && (c * d);                     /* Message 4109 */
}

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents