12-11-2013, 12:43 PM
The examples can be expanded as follows:
cha += u8a is the same as cha = cha + u8a
u8a += cha is the same as u8a = u8a + cha
Appendix D ("Addition with char) shows that the essential type of the right hand side of both of these expressions is Essentially character, meaning that the first assignment is permitted but the second is not as it violates Rule 10.2.
The document is incorrect in that it should state that u8a+=cha is compliant with exception 1 of rule 10.4, but violates rule 10.3.
cha += u8a is the same as cha = cha + u8a
u8a += cha is the same as u8a = u8a + cha
Appendix D ("Addition with char) shows that the essential type of the right hand side of both of these expressions is Essentially character, meaning that the first assignment is permitted but the second is not as it violates Rule 10.2.
The document is incorrect in that it should state that u8a+=cha is compliant with exception 1 of rule 10.4, but violates rule 10.3.
Posted by and on behalf of the MISRA C Working Group