Uninitialized local variables
void setup() { int status; pinMode(13, OUTPUT); digitalWrite(13, status); }
Although the variable status is not explicitly initializedAs pointed out by Edgar Bonet in the comments, local variables like status in the code above, are not implicitly initialized by the C++ compiler does that for you. It sets it as zero. So, even though it's not explicit in the code, we know thatoutcome of the led won't be litcode above is indeterminate. However, it's not considered good practice to rely onTo avoid that behaviour. Try and, make sure you always assign values to your local variables as.
Things are a bit different with global and static variables:
Global and static variables are guaranteed to be initialized to 0 by the C standard.
Source: AVR Libc Reference Manual - Frequently Asked Questions - Shouldn't I initialize all my variables?
That means you shouldn't worry about initializing them to 0 in your code. In fact, you should really avoid it makes, as the code clearerinitialization may waste memory. Only initialize them to values other than 0.
The first problem here is that you don't know what will be assigned to v, but worse is that you don't know what you messed up with the assignment to position -100 of array. The good news is that you only messed up with RAM and not with the Flash memory, thus your program is safe.
The first call to funcPtr() will actually be a call to doSomething(). Calls like the second one may lead to undefined behavior. In this case, it will continue execution from memory address 0, which seems to be the start of the sketch (I just tested and that's equivalent to a soft boot - it doesn't even go through the bootloader).