MISRAC2012-Rule-10.6
In this section:
Synopsis
(Required) The value of a composite expression shall not be assigned to an object with wider essential type
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
The value of a composite expression is assigned to an object with wider essential type.
Coding standards
- MISRA C:2012 Rule-10.6
(Required) The value of a composite expression shall not be assigned to an object with wider essential type
Code examples
The following code example fails the check and will give a warning:
#include <stdint.h>
void example(void) {
uint16_t a = 5;
uint16_t b = 10;
uint32_t c;
c = a + b;
}
The following code example passes the check and will not give a warning about this issue:
#include <stdint.h>
void example(void) {
uint16_t a;
uint16_t b;
b = a + a;
}