MISRAC2012-Rule-10.7
Synopsis
(Required) 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
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
An operator in which the usual arithmetic conversions are performed was found, where a composite expression is used as one of the operands, but the other operand is of wider essential type.
Coding standards
- MISRA C:2012 Rule-10.7
(Required) 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
Code examples
The following code example fails the check and will give a warning:
void example(long l, short s) {
l * ( s + s ); /* Implicit conversion of (s + s) */
}
The following code example passes the check and will not give a warning about this issue:
void example(long l, short s) {
l * s + s; /* No composite conversion */
}