In this section:

Overview

This error is generated whenever a program operates on a memory region that is unknown to Insure++. This can come about in two ways:

  • Errors in user code that result in pointers that don’t point at any known memory block.
  • Compiling only some of the files that make up an application. This can result in Insure++ not knowing enough about memory usage to distinguish correct and erroneous behavior.

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

CodeDescriptionEnabledReportedPlatform
EXPR_WILD

Expression uses a wild pointer

(error)RuntimeWindows/Unix


Problem 1

The following code attempts to use the address of a local variable but contains an error at line 8; the address operator (&) has been omitted.

/*
 * File: expwld1.c
 */
main()
{
	int i = 123, j=345, *a;

	a = i;
	if(a > &i)
		a = &j;
	return (0);
}

Diagnosis at Runtime

[expwld1.c:9] **EXPR_WILD**
>>		 if(a > &i)
	Expression uses wild pointer: a > &i
	Pointer : 0x0000007b
	Stack trace where the error occurred:
			main() expwld1.c,
  • 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 wild pointer.
  • Line 5: Stack trace showing the function call sequence leading to the error.

Most compilers will generate warning messages for this error because the assignment in line 8 uses incompatible types.

Problem 2

The same problem can also occur when using union types. The following code first assigns the pointer element of a union but then overwrites it with another element before finally attempting to use it.

/*
 * File: expwld2.c
 */
union {
	int *ptr;
	int ival;
} u;

main()
{
	int i = 123, j=345;

	u.ptr = &i;
	u.ival = i;
	if(u.ptr > &j)
		u.ptr = &j;
	return (0);
}

This code will not generate compile time errors.

Diagnosis at Runtime

[expwld2.c:15] **EXPR_WILD**
>>	 if(u.ptr > &j)
Expression uses wild pointer: u.ptr > &j
Pointer : 0x0000007b
Stack trace where the error occurred:
		main() expwld2.c, 15
  • Line 2: Source line at which the problem is 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 5: Stack trace showing the function call sequence leading to the error. 

Repair

The simpler types of problem are most conveniently tracked in a debugger by stopping the program at the indicated source line. You should then examine the illegal value and attempt to see where it was generated. Alternatively you can stop the program at some point prior to the error and single-step it through the code leading up to the error. “Wild pointers” can also be generated when Insure++ has only partial information about your program’s structure. For more information on this topic, contact Parasoft’s Quality Consultants.

  • No labels