Not sure this is well documented on the web, but I had some fun with the PIC18F26K40 recently - basically anything using/accessing constants, such as a const int, or a const char array (an inline string for example) was not returning the valid content of the constant.
I put this down to my primitive embedded skills at first, but it turns out there is a bug in this particular PIC (and the 27K40 according to others) that means without setting some register at powerup, the PIC fails to successfully return values from program memory reads.
My experience was with a inline string (which was defined as const char xx[] = "XXX") and with a const int. In my experience the string was full of NULs, and the int was 0, regardless of what the code said.
Here is the errata (see section 3):
http://ww1.microchip.com/downloads/en/DeviceDoc/80000712A.pdfAnd here is step-by-step way to implement the workaround in MPLABX:
http://www.microchip.com/forums/FindPost/957920Apparently this workaround is implemented automatically in XC8 1.40 but I have not tested this. The workaround does work and the PIC behaves fine now.