10-07-2025, 12:54 PM
Rule 10.8 applies to composite expressions.
You can address this by one of two methods:
1. Deviate Rule 10.8
2. Separate the concerns, by splitting into two statements:
Assuming int32_t a, b;
int32_t s = a + b; // Addition: may overflow, leading to UB
uint32_t u = (uint32_t) s; // Cast to different essential type
You can address this by one of two methods:
1. Deviate Rule 10.8
2. Separate the concerns, by splitting into two statements:
Assuming int32_t a, b;
int32_t s = a + b; // Addition: may overflow, leading to UB
uint32_t u = (uint32_t) s; // Cast to different essential type
Posted by and on behalf of the MISRA C Working Group