Skip to main content

IAR Embedded Workbench for Arm 9.70.x

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

In this section:
Synopsis

(Required) An empty throw (throw;) shall only be used in the compound-statement of a catch handler.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Unsafe rethrow of exception. This check is identical to THROW-empty, MISRAC++2023-18.1.2.

Coding standards
MISRA C++ 2023 18.1.2

(Required) An empty throw shall only occur within the compound-statement of a catch handler

Code examples

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

void func()
{
  try
  {
    throw;
  }
  catch (...) {}
}

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

void func()
{
  try
  {
    throw (42);
  }
  catch (int i)
  {
    if (i > 10)
    {
      throw;
    }
  }
}