MISRA C++:2023 Rule 18.5.2
Description
Rule Definition
Program-terminating functions should not be used. 1
Rationale
Standard library functions such as std::abort(),
               std::exit(), std::quick_exit(),
               std::terminate(), and std::_Exit() terminate
            the program immediately. When the program terminates due to calls to these functions, it
            is implementation-dependent whether the compiler releases the allocated resources and
            unwinds the stack.
Not releasing allocated resources or failing to unwind the stack can lead to issues such as memory leaks or permanently locked files. Avoid calling these program-terminating functions.
Polyspace Implementation
The rule checker reports a violation if you explicitly call one of these functions in your code:
- Unsafe termination functions such as - std::_Exit(),- std::abort(), and- std::quick_exit()
- The function - std::terminate()
- The function - std::exit()
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: Exception Handling | 
| Category: Advisory | 
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.