Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2004-10.2_b

In this section:
Synopsis

(Required) The value of an expression of floating type shall not be implicitly converted to a different underlying type if: (b) the expression is complex.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

An expression of floating type was found that is implicitly converted to a narrower underlying type.

Coding standards
MISRA C:2004 10.2

(Required) The value of an expression of floating type shall not be implicitly converted to a different underlying type if: a. it is not a conversion to a wider floating type, or b. the expression is complex, or c. the expression is a function argument, or d. the expression is a return expression.

Code examples

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

void example(void) {
  float pc[10];
  double x = pc[5] + 5; // architecture dependent
}

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

void example(void) {
  float pc[10];
  // complex expression without an implicit cast.
  float x = pc[5] + 5;
}