Exception handler hidden by previous handler
catch statement is not reached because of an earlier catch statement for the same exception
Description
This defect occurs when a catch statement is not reached because a previous catch statement handles the exception.
For instance, a catch statement accepts an object of a class my_exception and a later catch statement accepts one of the following:
An object of the
my_exceptionclass.An object of a class derived from the
my_exceptionclass.
Risk
Because the catch statement is not reached, it is effectively dead code.
Fix
One possible fix is to remove the redundant catch statement.
Another possible fix is to reverse the order of catch statements. Place the catch statement that accepts the derived class exception before the catch statement that accepts the base class exception.
Examples
Result Information
| Group: C++ Exception |
| Language: C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax:
EXCP_HANDLER_HIDDEN
|
| Impact: Medium |
PQL Name:
std.defects.EXCP_HANDLER_HIDDEN
|
Version History
Introduced in R2015b
See Also
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)