If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type
If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed, then the other operand shall not have wider essential type.
A composite expression is a nonconstant expression using a composite operator. In the Essential Type Model, composite operators are:
Multiplicative (*, /, %)
Additive (binary +, binary -)
Bitwise (&, |, ^)
Shift (<<, >>)
Conditional (?, :)
Restricting implicit conversion on composite expressions mean that sequences of arithmetic operations within expressions must use the same essential type. This restriction reduces confusion and avoids loss of value, sign, precision, or layout. However, this rule does not imply that all operands in an expression are of the same essential type.
For more information on essential types, see MISRA C:2012 Rule
10.1.
The right operand shall not have wider essential type than the left operand which is a composite expression.
The left operand shall not have wider essential type than the right operand which is a composite expression.
If you expect a rule violation but do not see it, refer to the documentation of Polyspace® Code Prover™ or Polyspace Code Prover Server™.
| Group: The Essential Type Model |
| Category: Required |
| AGC Category: Advisory |