[previous] 4103 [next] Both operands of arithmetic or bitwise operator are 'Boolean' expressions.
Arithmetic type - Operands

Both operands of this arithmetic, bitwise exclusive OR (^) or shift (<<, >>) operator are expressions which are effectively Boolean. This is bad practice at best and probably a mistake.

For example:


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

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

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

    x = (a > b) ^ (c > d);             /* Message 4103 */

    x = (a > b) << (c > d);            /* Message 4103 */

    return x;
}


No MISRA C:2012 Rules applicable to message 4103


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