Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Dir-4.12

In this section:
Synopsis

(Required) Dynamic memory allocation shall not be used.

Enabled by default

Yes

Severity/Certainty

Low/High

lowhigh.png
Full description

Dynamic memory allocation found.

Coding standards
MISRA C:2012 Dir-4.12

(Required) Dynamic 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) {
  int * x = malloc(sizeof(int));
}
void example(void) {
  int * x = new int[10];
}

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

void example(void) {
  int x[10];
  int * y = x;
}