AUTOSAR C++14 Rule A15-0-3
Description
Rule Definition
Exception safety guarantee of a called function shall be considered.
Rationale
The exception safety level of a function affects the function behavior. Functions that have a basic exception safety do not modify the class invariant when they exit with an exception. Functions that have a strong exception safety restores the class invariant to the state it was before the function call.
If a function provides neither of these exception safety, calling it might lead to unexpected behavior. For instance, an external function might exit with an exception for a specific input. When a client uses this function, the exception might be unexpected, resulting in a memory leak or program termination.
Polyspace Implementation
The emplace()
method uses constructors of objects to construct them
in-place within the containers. An exception arising from this method leaves the constructor
in an invalid state. If the called constructors contain throw()
statements, or calls a function that raises exception, Polyspace® flags the emplace()
method.
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: Required, Non-automated |
Version History
Introduced in R2022a