Try to compare compiler settings (Settings -> Compiler and Debugger ...) in both enviroments. I think there will be differences in some optimalization flags.
Great Answer!
I deselected the "-O" on my local machine,the code is then compiled fine,I guess it's a problem of gcc.
But I accidently discovered a small mistake of "codeblocks-8.02mingw-setup.exe" after comparison:
In the "Toolchain executables" tab,"Make program" is set to "make.exe" by default while there's no such file in MinGW's directory,but "mingw32-make.exe" instead,like the one auto-detected on my virtual machine.