Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2012-Rule-21.3

In this section:
Synopsis

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

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Uses of malloc, calloc, realloc, aligned_alloc, or free were found. This check is identical to MISRAC2004-20.4, MISRAC++2008-18-4-1, MISRAC++2023-21.6.1_a.

Coding standards
MISRA C:2004 20.4

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

MISRA C++ 2008 18-4-1

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

MISRA C++ 2023 21.6.1

(Advisory) Dynamic memory should 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) {
}