In this section:

Overview

This problem occurs when an attempt is made to copy a pointer with an invalid value or that Insure++ did not see allocated. There are two causes of this behavior:

  • Errors in the code resulting in pointers that don’t point to any known memory block.
  • Compiling only some of the files that make up an application. As a result, Insure++ may not have enough information about memory usage to distinguish correct and erroneous behavior.

This section focuses on the first type of problem described above. For information about the second type of problem, contact Parasoft’s Quality Consultants.

CodeDescriptionEnabledReportedPlatform
COPY_UNINIT_PTR

Attempt to copy a wild pointer

(error)RuntimeWindows/Unix


Problem

In the following code, the function attempts to use the address of a variable, but it contains an error at line 9–the address operator (&) has been omitted.

*
* File: copywild.cpp
*/

main() 
{
	int a = 123, *b;

	b = a;
	return 0;
}

Diagnosis at Runtime

[copywild.c:9] **COPY_WILD**
>> 		b = a;
	Copying wild pointer: a 
	Pointer : 0x0000007b
	Stack trace where the error occurred:
		main() copywild.c, 9
  • Line 2: Source line at which the problem was detected.
  • Line 3: Description of the problem and the name of the parameter that is in error. 
  • Line 4: Value of the bad pointer.
  • Line 6: Stack trace showing the function call sequence leading to the error.

Most compilers will generate warning messages for this error since the assignment uses incompatible types.

  • No labels