Search

ParaSoft

HOME
PRODUCTS
SUPPORT
ABOUT
WHAT'S NEW
EVENTS


Insure++

Quick facts

Add-on Modules:
   -INUSE
   -TCA

Comparisons

Technical Papers

Support & Manuals

FAQs

Recent Reviews

User Testimonials

Press Releases


Insure tool to debug c++





Insure++ Reference - EXPR_BAD_RANGE



EXPR_BAD_RANGE

Expression exceeded 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.

Problem

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]; bug
	11:		return (0);
	12:	}

Diagnosis


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


  1. Source line at which the problem was detected.
  2. Description of the problem and the expression that is in error.
  3. Description o the memory block to which the out of range pointer used to point, including the location at which it is declared.
  4. Stack trace showing the function call sequence leading to the error.

Repair

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
Tools to debug c++ and java
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft