Just a quick heads up for people using the PIC18F4550 (USB enabled MCU).
Most of the memory banks in the linker script are assigned to the USB stack. I was porting my mapping robot program over to the 18F4550 and it started going haywire, if I modified a value in one of the mapping arrays then it started modifying the value of an INT that was in no way related to it whatsoever.
Worse still... when using the debug simulator, then even more of the general purpose data memory is used up on the debugging mode.
So if anybody tries writing programs for this mcu and notice very strange behaviour then this is probably why.
I got around the issue by changing the gpr1 and gpr2 registers to span the USB registers to allow more data memory for the program but unfortunately this removes the USB functionality... (which was the reason for porting the code in the first place
PS. I spent about 8 hours looking for bugs in the code until I realised. I hope this post prevents anybody else wasting so much time.