Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC2012-Rule-9.2

In this section:
Synopsis

(Required) The initializer for an aggregate or union shall be enclosed in braces.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

An initializer for an aggregate or union was found that is not enclosed in braces.

Coding standards
MISRA C:2012 Rule-9.2

(Required) The initializer for an aggregate or union shall be enclosed in braces

Code examples

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

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

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

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