[previous] 3377 [next] Operand of a logical && or || operator is a constant expression which is not a 'Boolean' value.
Arithmetic type - Operations

A logical && or || operator has been used with an operand which is a constant expression, but the value of the expression is neither 0 nor 1.

The ISO:C90 language does not support an explicit Boolean type, but there are certain operators which generate a result of type int with a value of 0 or 1. The result may be described as effectively Boolean.

&& and || are operators which act on operands which are interpreted in a Boolean sense. The value of the operands are permitted to be of any value but are implicitly compared with 0. Message 3377 is generated if an operand is a constant value other than 0 or 1.

For example:


/*PRQA S 3199,3120,3211,3227,3408 ++ */

#define MASK 0x04u

extern void foo(int bl)
{
    if ((bl != 0) && MASK)                    /* Message 3377 */
    {
    }

}


No MISRA C:2012 Rules applicable to message 3377


See also:

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