Insure++ Reference - COPY_BAD_RANGE
This error is generated whenever an attempt is made to copy a pointer
which points outside a valid range. It is not necessarily a serious
problem, but may indicate faulty logic in the coding. Therefore,
this error is suppressed by default.
The following code illustrates the problem in a simple way. In line 7,
the pointer a is initialized as an array of 10
chars . The next line then attempts to make pointer
b point to an area which has not been allocated.
The resulting pointer is not valid.
1: /*
2: * File: copybad.C
3: */
4: int main() {
5: char *a, *b;
6:
7: a = new char [10];
8: b = a + 20;
9: return 0;
10: }
1. [copybad.C:8] **COPY_BAD_RANGE**
>> b = a + 20;
2. Copying pointer which is out-of-range: a + 20
3. Pointer : 0x0007c124
Actual block : 0x0007c110 thru 0x0007c119 (10 bytes)
a, allocated at:
main() copybad.C, 7
4. Stack trace where the error occurred:
main() copybad.C, 8
- Source line at which the problem was detected.
- Brief description of the problem.
- Description of the pointer which is out-of-range.
- Stack trace showing the function call sequence leading to
the error.
The simple way to avoid this problem is to not copy the invalid pointer.
There may be an incorrect boundary case in your code causing the problem.
BAD_PARM
COPY_DANGLING
|