http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58042
Bug ID: 58042 Summary: MinGW GCC produces problematic x64 executable with -O2 -static -flto -m64 Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: stanley82521 at gmail dot com The toolchain I use is MinGW-builds from Sourceforge, which uses runtime lib provided by MinGW-w64 project, and this issue also appears in Ruben's build from MinGW-w64. The code snipe below can be used to reproduce the problem: #include<iostream> int main(){ std::cout << "Foo = " << 101 << std::endl; return 0; } With "-O2 -flto -static -m64", GCC can produce a problematic x64 executable, which will crash during execution. It will crash after output "Foo = ". This issue appeared before the GCC 4.8.0 release and lasts till now, existing in the 4.8.1 and testing 4.9.0 build provided by MinGW-builds project. This problem seems not a bug of MinGW-w64 runtime because compiling the source file without any option described above can't reproduce the problem.