Insure++ Reference - PARM_WILD
This error is generated whenever a parameter is declared as an array
but the actual value passed when the function is called points to no
known memory block.
This can come about in several ways:
- Errors in user code that result in pointers that do not 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 discussion centers on the first type of problem described here. A
detailed discussion of the second topic, including samples of its generation
and repair can be found in
"Interfaces".
The following code attempts to pass the address of a local variable to the
routine foo but contains an error at line 14 - the address operator
(& ) has been omitted.
1: /*
2: * File: parmwld1.c
3: */
4: void foo(a)
5: int a[];
6: {
7: return;
8: }
9:
10: main()
11: {
12: int i = 123, *a;
13:
14: a = i;
15: foo(a);
16: return (0);
17: }
[parmwld1.c:6] **PARM_WILD**
1. >> {
2. Array parameter is wild: a
3. Pointer : 0x0000007b
Stack trace where the error occurred:
4. foo() parmwld1.c, 6
main() parmwld1.c, 15
- Source line at which the problem was detected.
- Description of the problem and the name of the parameter
that is in error.
- Value of the bad pointer.
- Stack trace showing the function call sequence leading to
the error.
Note that most compilers will generate warning messages for this error
since the assignment uses incompatible types.
A more insidious version of the same problem can 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 passing it to a function.
1: /*
2: * File: parmwld2.c
3: */
4: union {
5: int *ptr;
6: int ival;
7: } u;
8:
9: void foo(a)
10: int a[];
11: {
12: return;
13: }
14:
15: main()
16: {
17: int i = 123;
18:
19: u.ptr = (int *) &i;
20: u.ival = i;
21: foo(u.ptr);
22: return (0);
23: }
Note that this code will not generate compile time errors.
[parmwld2.c:11] **PARM_WILD**
1. >> {
2. Array parameter is wild: a
3. Pointer : 0x0000007b
Stack trace where the error occurred:
4. foo() parmwld2.c, 11
main() parmwld2.c, 21
- Source line at which the problem was detected.
- Description of the problem and the name of the parameter
that is in error.
- Value of the bad pointer.
- Stack trace showing the function call sequence leading to
the error.
This problem is 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
through the code leading up to the problem.
Note that wild pointers can also be generated when Insure++ has
only partial information about your program's structure. This issue is
discussed extensively in
"Interfaces".
PARM_UNINIT_PTR
READ_BAD_INDEX
|