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