Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2023-18.1.1

In this section:
Synopsis

(Required) An exception object shall not have pointer type

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Throw of exceptions by pointer. This check is identical to MISRAC++2008-15-0-2, THROW-ptr.

Coding standards
CERT ERR09-CPP

Throw anonymous temporaries and catch by reference

MISRA C++ 2008 15-0-2

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

Code examples

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

#ifndef __EXCEPTIONS
    #error "IGNORE_TEST: requires exceptions"
#endif

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:

#ifndef __EXCEPTIONS
    #error "IGNORE_TEST: requires exceptions"
#endif

class Except {};

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