Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category
Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category.
The use of implicit conversions between types can lead to unintended results, including possible loss of value, sign, or precision.
For more information on essential types, see MISRA C:2012 Rule
10.1.
The checker raises a violation of this rule if the two operands of an operation have different essential types. The checker message states the types detected on the two sides of the operation.
The checker does not raise a violation of this rule:
If one of the operands is the constant zero.
If one of the operands is a signed constant and the other operand is unsigned, and the signed constant has the same representation as its unsigned equivalent.
For instance, the statement u8b =
u8a + 3;, where u8a
and u8b are unsigned
char variables, does not violate the
rule because the constants 3
and 3U have the same
representation.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: The Essential Type Model |
| Category: Required |
| AGC Category: Advisory |