I know dereferencing a null pointer is undefined - but I would like to know what happens on a specific target - an MSP430.
I don't have a board to load this on in front of me to test this out right now.
What would happen if I did this (or similar)?
int * foo = NULL;
(*foo)++; //Crash?
Location 0x0 is in the SFR range and is reserved.
Would it generate a PUC/POR? Or would it silently "work"?
The assembly generated is
;int * foo = NULL;
clr.w R15
;(*foo)++;
inc.w R15
So location 0x0 is literally being incremented by 1.
When I run this in the simulator I see the value at address 0x0 go from 0 to 1. I get no warnings in the debug log and the program exits normally.
I am using the IAR EW430 compiler/assembler/simulator.