
range checks on arrays and pointers


	
pointer variable


	base of the memory block pointed to

	last location of the memory block pointed to	

	current address pointed to

	dynamic memory block pointed to yes/no		(dealloc if y, range check if y or n)




steps required for implementation


1. perform the following range checks when expressions of these types appear

	
		ptr++		check that the new address is not past the end of the block

		++ptr		check that the new address is not past the end of the block

		ptr + x		check that the address calculated is not past the end of the block

		ar1[ x ]	check that the address calculated is not outside the array range


		ptr--		check that the new address is not before the start of the block

		--ptr		check that the new address is not before the start of the block

		ptr - x		check that the address calculated is not before the start of the block



2. calculate a new pointer value with all values updated


		ptr2 = ptr1 + 5;





implementation point


	before an increment instruction 

	before a decrement instruction

	after addition, if one of the operands is a pointer

	after subtraction, if the left operand is a pointer


	before array/pointer dereference	







