In this section:
This error is generated whenever an uninitialized pointer is copied. This error category will be disabled if full uninitialized memory checking is in effect (the default). In this case, errors are detected in the READ_UNINIT_MEM
category instead.
|
In the following code, the a
pointer in line 5 is declared but never initialized. Therefor, when an attempt is made in line 7 to copy a
to b
, an error is generated.
* * File: copyunin.cpp */ int main() { char *a, *b; b = a; return 0; } |
[copyunin.cpp:7] **COPY_UNINIT_PTR** >> b = a; Copying uninitialized pointer: a Stack trace where the error occurred: main() copyunin.cpp, 7 |
This problem is usually caused by omitting an assignment or allocation statement that would initialize a pointer. The example code given could be corrected by assigning a value to a
before reaching line 7.