MISRAC2004-9.2
In this section:
Synopsis
(Required) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A non-zero array initialization was found that does not exactly match the structure of the array declaration. This check is identical to MISRAC++2008-8-5-2.
Coding standards
- MISRA C:2004 9.2
(Required) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures.
- MISRA C++ 2008 8-5-2
(Required) Braces shall be used to indicate and match the structure in the nonzero initialization of arrays and structures.
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int y[3][2] = { { 1, 2 }, { 4, 5 } };
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int y[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
}