http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51962
Bug #: 51962 Summary: Compiling with -O3 and using the same input produces a different result Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: mario.ach...@gmail.com Created attachment 26423 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26423 The simple C++ code that causes the "bug". Compile the following simple code without -O3, and run. Now compile it with -O3 option (for optimization), run again. Surprisingly 2 different outputs appear. I have made the program as minimal as possible and traced back the error to the following line: if (((k-x[j])*(k-x[j])+(y[j]-ya)*(y[j]-ya))<=r[j]*r[j]) { found1 = true; } (line 17 in the code) Comment this and the problem is solved. This caused a huge problem that took me around an hour to figure out that it was related to compiler optimization. I have provided the simplest case I could find causing the error. Thank you for your time and hope you fix it soon. Please keep me updated.