This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81503] New: Wrong code at -O2
- From: "babokin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 21 Jul 2017 05:40:30 +0000
- Subject: [Bug tree-optimization/81503] New: Wrong code at -O2
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503
Bug ID: 81503
Summary: Wrong code at -O2
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: babokin at gmail dot com
Target Milestone: ---
gcc trunk, rev250367, x86_64.
> cat f.cpp
#include <stdio.h>
unsigned short a = 41461;
unsigned short b = 3419;
int c = 0;
void foo() {
if (a + b * ~(0 != 5))
c = -~(b * ~(0 != 5)) + 2147483647;
}
int main() {
foo();
printf("%d\n", c);
return 0;
}
> g++ f.cpp -O0; ./a.out
2147476810
> g++ f.cpp -O2; ./a.out
-2147483648