Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-13.1

In this section:
Synopsis

(Required) Initializer lists shall not contain persistent side effects

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

The initalization list of an array contains side effects. This check is identical to SPC-init-list.

Coding standards
MISRA C:2012 Rule-13.1

(Required) Initializer lists shall not contain persistent side effects

Code examples

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

volatile int v1;

extern void p ( int a[2] );

int x = 10;

void example(void) {
  int a[2] = { v1, 0 };
  p( (int[2]) { x++, x-- });
}

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

void example(void) {
  int a[2] = { 1, 2 };
}