MISRA C:2023 Rule 14.3
Description
Rule Definition
Controlling expressions shall not be invariant1 .
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,switchfor,while,do-whileTernary (
?:) 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 |
Version History
Introduced in R2024a1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.