Insure++ Reference - EXPR_BAD_RANGE
This error is generated whenever an expression uses a pointer that is
outside its legal range. In many circumstances, these pointers are then
turned into legal values before use (e.g., code generated by automated
programming tools such as lex and
yacc ), so this error category is suppressed by
default. If used with their illegal values, other Insure++ errors
will be displayed which can be tracked to their source by re-enabling
this error class.
In this code, the pointer a initially points to a
character string. It is subsequently incremented beyond the end of the
string. When the resulting pointer is used to make an array reference, a
range error is generated.
1: /*
2: * File: exprange.c
3: */
4: main()
5: {
6: char *a = "test";
7: char *b;
8:
9: a += 6;
10: b = &a[1];
11: return (0);
12: }
1. [exprange.c:10] **EXPR_BAD_RANGE**
>> b = &a[1];
2. Expression exceeded range: a[1]
Index used : 1
3. Pointer : 0x0000e226
In block : 0x0000e220 thru 0x0000e224 (5 bytes)
a, declared at exprange.c, 6
4. Stack trace where the error occurred:
main() exprange.c, 10
- Source line at which the problem was detected.
- Description of the problem and the expression that is in error.
- Description o the memory block to which the out of range pointer
used to point, including the location at which it is declared.
- Stack trace showing the function call sequence leading to the
error.
In most cases, this error is caused by incorrect logic in the code
immediately prior to that at which the message is generated. Probably
the simplest method of solution is to run the program under a debugger
with a breakpoint at the indicated location.
If you cannot find the error by examining the values of other variables
at this location, the program should be run again, stopped somewhere shortly
before the indicated line, and single-stepped until the problem occurs.
DELETE_MISMATCH
EXPR_DANGLING
|