If in doubt, run some code :) I cracked some similar (slightly less disgusting) test code (win32 C ++ app in msvs 2k10)
int _tmain(int argc, _TCHAR* argv[]) { int a = 0; volatile int b = 0; a = 1;
When compiled for release, I am allowed to stop at 2 and 4, but not 1 and 3.
My conclusion is that type defines behavior and 1 and 3 have been optimized. Intuition supports this: otherwise, the compiler would have to keep a list of the types of all memory locations listed as mutable and check each access (hard, ugly), and not just associate it with the identifier type (simpler and more intuitive).
I also suspect that this is specific to the compiler (and possibly a certain flag even inside the compiler) and will be tested on any platform before depending on this behavior.
Actually, scratch this, I’ll just try not to depend on this behavior :)
In addition, I know that you specifically asked about arrays, but I doubt it matters. You can easily crack the same test code for arrays.
davec source share