Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
langcpp
// classesClasses used for exception handling.
class B {};
class D : public B {};

void f() {
  try {
    // ...
  } catch (B &b) {
    // ...
  } catch (D &d) {
    // ...
  }

}

Compliant Solution

In this compliant solution, the first handler will catch all exceptions of class D, and the second handler will catch all the other exceptions of class B.

Code Block
bgColor#ccccff
langcpp
// classesClasses used for exception handling.
class B {};
class D : public B {};

void f() {
  try {
    // ...
  } catch (D &d) {
    // ...
  } catch (B &b) {
    // ...
  }

}

Risk Assessment

Exception handlers with inverted priorities cause unexpected control flow when an exception occurs of the derived type.

...

Tool

Version

Checker

Description

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

CP1.ERR36

Fully implemented

PRQA QA-C++
Include Page
PRQA QA-C++_vV
PRQA QA-C++_vV
4040,4034 

Related Vulnerabilities

...