Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-0-1-3

In this section:
Synopsis

(Required) A project shall not contain unused variables.

Enabled by default

Yes

Severity/Certainty

Low/High

lowhigh.png
Full description

A variable is never read or written during execution. This check is identical to RED-unused-var-all.

Coding standards
CERT MSC13-C

Detect and remove unused values

CWE 563

Unused Variable

Code examples

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

int example(void) {
  int x;  //this value is not used
  
  return 0;
}

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

int example(void) {
  int x = 0;  //OK - x is returned
  
  return x;
}