MISRA C++:2023 Rule 0.0.1
Description
Rule Definition
A function shall not contain unreachable statements.
Rationale
Statements that are unreachable from the entry point of a function often indicate an error in the program logic. Unless the program is using an undefined behavior, an unreachable block cannot be executed and does not have any effect on the program outputs.
Polyspace Implementation
The rule checker reports a violation:
When a section of code cannot be reached because of a previous break in control flow using one of these statements:
break
andreturn
goto
Trivial infinite loops such as
while(1)
When a
catch
statement is not reached because a previouscatch
statement handles the exception thrown.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Language independent issues |
Category: Required |
Version History
Introduced in R2024b