Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC++2008-15-0-2

In this section:
Synopsis

(Advisory) An exception object should not have pointer type.

Enabled by default

No

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Throw of exceptions by pointer. This check is identical to THROW-ptr, MISRAC++2023-18.1.1.

Coding standards
CERT ERR09-CPP

Throw anonymous temporaries and catch by reference

MISRA C++ 2023 18.1.1

(Required) An exception object shall not have pointer type

Code examples

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

class Except {};

Except *new_except();

void example(void)
{
    throw new Except();
}

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

class Except {};

void example(void)
{ 
    throw Except();
}