So, I've done a simple test. For loop behavior heavily depends on optimization level asked from the compiler. E.g. in Default build mode it writes a pointer to the variable and therefore the loop variable will indeed keep the value it was last assigned during the loop.
However -O4 (didn't test others) in turn uses registers instead of a pointer to gain speed (and is right to do so
). As a result the variable has its default value (i.e. undefined). See first screenshot attached. Unfortunately it doesn't show the warning - which this topic is about
Moreover, it's smart enough to notice that the loop doesn't do anything and skips the loop entirely showing a compiler-time warning about uninitialized variable. See the second screenshot.
What happens under the hood can be seen in Assembler window.