MISRA C:2025 Rule 14.3
R2026bDescription
Controlling expressions shall not be invariant 1 .
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
The checker also flags expressions that evaluate to a constant through arithmetic or logical operations on literals, such as !0, 1 + 1, or 1 == 1.
Polyspace Bug Finder™ flags some violations of MISRA C:2025 Rule 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 |
PQL Name:
std.misra_c_2025.R14_3
|
Version History
Introduced in R2026bSee Also
1 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:2025
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.