In this section:

Overview

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.

CodeDescriptionEnabledReportedPlatform
COPY_UNINIT_PTR

Attempt to copy uninitialized pointer

(error)RuntimeWindows/Unix


Problem

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;
}

Diagnosis at Runtime

[copyunin.cpp:7] **COPY_UNINIT_PTR**
>> 			b = a;
	Copying uninitialized pointer: a
	Stack trace where the error occurred:
		main() copyunin.cpp, 7
  • Line 1: Source line at which the problem was detected.
  • Line 3: Brief description of the problem. 
  • Line 4: Stack trace showing the function call sequence leading to the error.

Repair

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.

  • No labels