Public bug reported:
As reported by Mike Mirzayanov on GCC Bugzilla:
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60766 and
http://codeforces.com/blog/entry/11450
Ubuntu 14.04 includes GCC 4.8.2 which is affected with bug.
Please upgrade to GCC 4.8.3 or later in which the bug is fixed.
Compile with -O2 and input 9
Compile the following code with -O2:
~
#include cstdlib
#include iostream
#include cstdio
using namespace std;
int main() {
int n;
cin n;
for (int x = 0; x = n; x++) {
if (n == x + (x + 1) + (x + 2)) {
cout x + 2 x + 1 x endl;
exit(0);
}
}
cout -1 endl;
return 0;
}
~
Start binary and enter 9
It will print -1, but expected output is 4 3 2.
** Affects: gcc (Ubuntu)
Importance: Undecided
Status: New
** Attachment added: Compile with -O2 and input 9
https://bugs.launchpad.net/bugs/1432250/+attachment/4345712/+files/compile%20with%20-O2%20and%20input%209.cpp
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1432250
Title:
[4.7 Regression] Wrong optimization with -O2
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc/+bug/1432250/+subscriptions
--
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs