MISRA C++:2023 Rule 0.0.1
Description
Rule Definition
A function shall not contain unreachable statements. 1
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: - breakand- return
- goto
- Trivial infinite loops such as - while(1)
 
- When a - catchstatement is not reached because a previous- catchstatement 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
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++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.