Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2023-21.6.1_a

In this section:
Synopsis

(Advisory) Dynamic memory should not be used

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Uses of new, delete malloc, calloc, realloc, or free were found. This check is identical to MISRAC++2008-18-4-1, MISRAC2004-20.4, MISRAC2012-Rule-21.3.

Coding standards
MISRA C:2004 20.4

(Required) Dynamic heap memory allocation shall not be used.

MISRA C:2012 Rule-21.3

(Required) The memory allocation and deallocation functions of <stdlib.h> shall not be used

MISRA C++ 2008 18-4-1

(Required) Dynamic heap memory allocation shall not be used.

Code examples

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

#include <stdlib.h>

void *example(void) {
  return malloc(100);
}

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

void example(void) {
}