MISRAC2012-Rule-9.4
In this section:
Synopsis
(Required) An element of an object shall not be initialized more than once.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
An object field was found that is initialized more than once. The last initialization will overwrite previous value(s).
Coding standards
- MISRA C:2012 Rule-9.4
(Required) An element of an object shall not be initialized more than once
Code examples
The following code example fails the check and will give a warning:
struct example {
int x;
int y;
};
struct example object = { .x = 100, .x = 200 };
// object = { .x = 100, .y = 0 };
The following code example passes the check and will not give a warning about this issue:
struct example {
int x;
int y;
};
struct example object = { .x = 100, .y = 200 };
// object = { .x = 100, .y = 200 };