MISRA C:2023 Rule 14.3
Description
Rule Definition
Controlling expressions shall not be invariant.
Rationale
If the controlling expression, for example an if
condition,
has a constant value, the non-changing value can point to a programming
error.
Polyspace Implementation
The checker reports a violation if the controlling expression of a control statement is
always true
or false
. The control statements that
Polyspace® checks include:
if
,switch
for
,while
,do-while
Ternary (
?:
) operator
Polyspace
Bug Finder™ flags some violations of MISRA C™ 14.3 through the Dead
code
and
Useless
if
checkers.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Control Statement Expressions |
Category: Required |
AGC Category: Required |