MISRA C++:2023 Rule 18.5.2
Description
Rule Definition
Program-terminating functions should not be used.
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()
, andstd::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