MISRA C++:2008 Rule 15-5-2
Where a function's declaration includes an exception-specification, the function shall only be capable of throwing exceptions of the indicated type(s)
Description
Rule Definition
Where a function's declaration includes an exception-specification, the function shall only be capable of throwing exceptions of the indicated type(s).
Polyspace Implementation
The checker flags situations where the data type of the exception thrown does not match the exception type listed in the function specification.
For instance:
void goo ( ) throw ( Exception ) { throw 21; // Non-compliant - int is not listed }
The checker limits detection to throw
statements that are in
the body of the function. If the function calls another function, the checker does
not detect if the called function throws an exception.
The checker does not detect throw
statements inside
catch
blocks.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Check Information
Group: Exception Handling |
Category: Required |
Version History
Introduced in R2013b