You are viewing a single comment's thread. Return to all comments →
Yes, the code is working without a crash because there is a statment to break the loop if condition match.
No it works probably because the 4 bytes before is accessible and contains 0.
This is a classical undefined behavior case and a case of « it works on my computer syndroma ».
Running compiling/running this code with a different compiler (or on a different arch) may break. Just test it with address sanitizer (-fsanitize=address in gcc/clang) or a similar tool …