10.4 violation for u8b + 2

Moderators: misra-c, david ward

Post Reply
Posts: 1
Joined: Tue Jan 19, 2016 12:25 pm
Company: Schaeffler Automotive Buehl

10.4 violation for u8b + 2

Post by fmteau » Mon Jan 18, 2021 1:27 pm

Hello MISRA Bulletin Board,

I understand mixing signed and unsigned variables in arithmetic operations can really lead to unexpected results,
but I really fail to see what is the risk in adding a constant value of 2 (SLTR of signed char) to an unsigned 8-bit (char) variable.

Could you please elaborate what can possibly go wrong in this case?

Thanks in advance.

Post Reply

Return to “8.10 The essential type model”