Could be. What GCC version are you using?
gcc.exe (Rev2, Built by MSYS2 project) 4.9.2
Also, when -O3 is used, does it help to declare reserved_heap_size
volatile, like this:
size_t volatile reserved_heap_size;
(You might need to change the extern declaration on w32heap.h as
well.)