Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC++2008-15-3-4 (C++ only)

In this section:
Synopsis

(Required) Each exception explicitly thrown in the code shall have a handler of a compatible type in all call paths that could lead to that point.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

There are calls to functions that are explicitly declared to throw an exception type that are not handled (or declared as thrown) by the caller. This check is identical to THROW-unhandled.

Coding standards

This check does not correspond to any coding standard rules.

Code examples

The following code example fails the check and will give a warning:

class E1{};

#ifndef __cpp_noexcept_function_type
void foo(int i) throw (E1) {
#else
void foo(int i) {
#endif
  if (i<0)
    throw E1();
}

int bar() {
  foo(-3);
}

The following code example passes the check and will not give a warning about this issue:

class E1{};

#ifndef __cpp_noexcept_function_type
void foo(int i) throw (E1) {
#else
void foo(int i) {
#endif
  if (i<0)
    throw E1();
}

int bar() {
  try {
    foo(-3);
  }
  catch (E1){
  }
}