Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC++2008-0-1-6

In this section:
Synopsis

(Required) A project shall not contain instances of non-volatile variables being given values that are never subsequently used.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A variable is assigned a value that is never used. This check is identical to RED-unused-val, MISRAC2012-Rule-2.2_c.

Coding standards
CWE 563

Unused Variable

MISRA C:2012 Rule-2.2

(Required) There shall be no dead code

Code examples

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

int example(void) {
  int x;
  x = 20;
  x = 3;
  return 0;
}

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

int example(void) {
  int x;
  x = 20;
  return x;
}