Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC++2008-0-1-4_b

In this section:
Synopsis

(Required) A project shall not contain non-volatile POD variables having only one use.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A global variable is only used once.

Coding standards
CWE 563

Unused Variable

Code examples

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

int x = 1;
int example(void) {
  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;
}