public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mario.achkar at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51962] New: Compiling with -O3 and using the same input produces a different result Date: Mon, 23 Jan 2012 11:23:00 -0000 [thread overview] Message-ID: <bug-51962-4@http.gcc.gnu.org/bugzilla/> (raw) 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: unassigned@gcc.gnu.org ReportedBy: mario.achkar@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.
next reply other threads:[~2012-01-23 11:09 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-23 11:23 mario.achkar at gmail dot com [this message] 2012-01-23 11:25 ` [Bug c++/51962] " redi at gcc dot gnu.org 2012-01-23 11:33 ` mario.achkar at gmail dot com 2012-01-23 11:43 ` mario.achkar at gmail dot com 2012-01-23 11:47 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-51962-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).