![]() |
![]() |
3377 | ![]() |
||||
![]() | |||||||
| 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 */
{
}
}
MISRA-C:2004 Rules applicable to message 3377:
| 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 ?:). |
See also:
![]() | ||
| 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 |