Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC++2008-8-5-1_c

In this section:
Synopsis

(Required) All variables shall have a defined value before they are used.

Enabled by default

Yes

Severity/Certainty

High/Medium

highmedium.png
Full description

One or more uninitialized or NULL pointers are dereferenced. This check is identical to PTR-uninit, MISRAC2004-9.1_c.

Coding standards
CERT EXP33-C

Do not reference uninitialized memory

CWE 457

Use of Uninitialized Variable

CWE 824

Access of Uninitialized Pointer

MISRA C:2004 9.1

(Required) All automatic variables shall have been assigned a value before being used.

Code examples

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

void example(void) {
  int *p;
  *p = 4;  //p is uninitialized
}

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

void example(void) {
  int *p,a;
  p = &a;
  *p = 4;  //OK - p holds a valid address
}