AUTOSAR C++14 Rule A15-4-4
A declaration of non-throwing function shall contain noexcept specification
Since R2021a
Description
Rule Definition
A declaration of non-throwing function shall contain noexcept specification.
Rationale
Specifying functions that do not raise exceptions by using the specifier
noexcept
or noexcept(true)
enables the compiler to
perform certain optimizations for these functions, such as omitting the exception handling
process. Specifying the exception specification of functions clearly communicates that you
expect the functions to not raise exceptions.
Specify functions that do not raise exceptions by using the specifier
noexcept
. If the exception specification of a function depends on a
template argument, use noexcept(<condition>)
. If the exception
specification of a function is unknown, assume it raises exceptions.
Polyspace Implementation
Polyspace® flags the definition of a callable entity, such as function, class or function template, or class constructors if the following is true:
The callable entity is defined. Polyspace does not flag functions that are declared but not defined. Polyspace checks function or class templates that have at least one instantiation.
The callable entity raises no exceptions. In case of templates of classes and functions, at least one instantiation raises no exception. When checking callable entities for exceptions, Polyspace assumes external functions with no definitions behave as
noexcept(true)
. For more information about how Polyspace checks if a callable entity raises an exception, see the Polyspace Implementation section ofAUTOSAR C++14 Rule A15-4-2
.The callable entity has no exception specification.
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, Automated |