Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-10.4_a

In this section:
Synopsis

(Required) Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Operands of an operator in which the usual arithmetic conversions are performed were found, that do not have the same essential type category.

Coding standards
MISRA C:2012 Rule-10.4

(Required) Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category

Code examples

The following code example fails the check and will give a warning:

void example(void) {
  unsigned int a = 5;
  float f = 0.001f;
  a + f;
}

The following code example passes the check and will not give a warning about this issue:

void example(void) {
  int a = 10;
  int b = 10;
  a + b;
}