MISRAC2012-Rule-9.1_a
In this section:
Synopsis
(Mandatory) The value of an object with automatic storage duration shall not be read before it has been set.
Enabled by default
Yes
Severity/Certainty
Low/High

Full description
A possible dereference of an uninitialized or NULL pointer was found. This check is identical to PTR-uninit-pos, CERT-EXP33-C_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:2012 Rule-9.1
(Mandatory) The value of an object with automatic storage duration shall not be read before it has been set
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
}