MISRAC2012-Rule-9.5_b
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

Full description
A flexible array member was found that is initialized with a designated initializer.
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:
struct A {
int x;
int y [];
};
struct A a1 = {1,{[1]=2}};
void example (void) {
}
The following code example passes the check and will not give a warning about this issue:
struct A {
int x;
int y [2];
};
struct A a1 = {1,{[1]=2}};
void example (void) {
}