Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-9.5_a

In this section:
Synopsis

(Required) Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Arrays, initialized with designated initializers but with no fixed length, were found.

Coding standards
MISRA C:2012 Rule-9.5

(Required) Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly

Code examples

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

void example(void) {
  int a1[] = { [0] = 1 };
}

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

void example(void) {
  int a1[10] = { [0] = 1 };
}