A variable is read without having been previously written.
In C/C++, all global or static variables are implicitly initialized to zero. Therefore, only local variables or dynamically allocated storage can be uninitialized. For local variables, the storage lifetime begins at the entry point to the block where the variable was declared (usually the subroutine itself). For dynamically allocated storage, the storage lifetime begins at the allocation point. An uninitialized read is possible if the program can execute along a path from the beginning of the storage lifetime to the indicated reference that does not encounter any assignment to that storage. This error indicates that at least one such possible execution path was found.
Sometimes the execution path that was identified cannot actually be executed. In this case, the error may be incorrect. However, there may be another path that can be executed that also performs an uninitialized read. Before dismissing this error as a false positive, make sure that no bad execution paths exist.
ID |
Observation |
Description |
---|---|---|
1 |
Uninitialized read |
The place the variable was read |
#include <stdio> int main(int argc, char **argv) { int unknown; // uninitialized variable printf("unknown value = %d\n", unknown); }
Copyright © 2010, Intel Corporation. All rights reserved.