MISRAC2004-9.1_c
In this section:
Synopsis
(Required) All automatic variables shall have been assigned a value before being used.
Enabled by default
Yes
Severity/Certainty
High/Medium

Full description
An uninitialized or NULL pointer that is dereferenced was found. This check is identical to PTR-uninit, MISRAC++2008-8-5-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.
- MISRA C++ 2008 8-5-1
(Required) All variables shall have a defined value before they are 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
}