Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2004-20.4

In this section:
Synopsis

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

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Detected use of malloc, calloc, realloc, or free. This check is identical to MISRAC++2008-18-4-1, MISRAC2012-Rule-21.3, MISRAC++2023-21.6.1_a.

Coding standards
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.

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) {
}