Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2012-Rule-10.8

In this section:
Synopsis

(Required) The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

A composite expression was found whose value is cast to a different essential type category or a wider essential type.

Coding standards
MISRA C:2012 Rule-10.8

(Required) The value of a composite expression shall not be cast to a different essential type category or a wider essential type

Code examples

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

void example(void) {
  int s16a = 3;
  int s16b = 3;

  // arithmetic makes it a complex expression
  long long x = (long long)(s16a + s16b);
}

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

void example(void) {
	int array[10];

	// A non complex expression is considered safe
	long x = (long)(array[5]);
}