[previous] 4110 [next] Operand of ! operator is an arithmetic or bitwise expression.
Arithmetic type - Operands REFERENCE - ISO:C90-6.3.3.3 Unary Arithmetic Operators

The operand of this logical negation operator (!) is derived from a bitwise or arithmetic operator. This is probably a mistake; perhaps a bitwise AND (&) or bitwise OR (|) was intended ?

For example:


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

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

    r = !(a || b);                    /* OK */

    r = !(a | b);                     /* Message 4110 */

}


MISRA-C:2004 Rules applicable to message 4110:

Rule  12.6  (Advisory) The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, != and ?:).


QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents