Weird compiler issues

You are using a ranged-based for loop and change the array inside it. This is undefined behaviour.
In my case it only triggered a breakpoint when debugging, and delayed the game for a second when executing.
Try using an index-based for loop or something else. If you post the code I could help you figuring out how you can change it.