[previous] 4105 [next] Right hand operand of arithmetic or bitwise operator is a 'Boolean' expression.
Arithmetic type - Operands

The right hand operand of this arithmetic, bitwise or shift shift operator is an expression which is effectively Boolean. This is bad practice at best and probably a mistake.

For example:


/*PRQA S 2017,3204,3227,3408 ++*/

int foo(int a, int b, int c)
{
    int x;

    x = a + (b > c);                /* Message 4105 */

    return x;
}


MISRA-C:2004 Rules applicable to message 4105:

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