Public bug reported: OS: Ubuntu 12.04.3 LTS gcc version: 4.6.3-1ubuntu5
It's a slightly modificated test case from gcc-4.6.3 testsuite (920612-1.c): int main(){ int a = 0; if ((int)((~0u) >> (1 + a))+1 > 0) abort(); exit(0); } It operates fine after compilation with -O0 or -O1 option (exit is executed), but changes behavior if compiled with -O2 or -O3 (abort is executed). Decompilation shows that optimizer reduces the code down to abort(); . Besides, if variable "a" is absent, bug is absent even with O3 optimization. So in simple case the optimizer takes into account the overflow, but misses it after a trivial change of the code. ** Affects: gcc-4.6 (Ubuntu) Importance: Undecided Status: New ** Tags: optimizer ** Description changed: OS: Ubuntu 12.04.3 LTS gcc version: 4.6.3-1ubuntu5 It's a slightly modificated test case from gcc-4.6.3 testsuite (920612-1.c): int main(){ - int a = 0; - if ((int)((~0u) >> (1 + a))+1 > 0) - abort(); - exit(0); + int a = 0; + if ((int)((~0u) >> (1 + a))+1 > 0) + abort(); + exit(0); } It operates fine after compilation with -O0 or -O1 option (exit is - executed), but changes behaiviour if compiled with -O2 or -O3 (abort is + executed), but changes behavior if compiled with -O2 or -O3 (abort is executed). Decompilation shows that optimizer reduces the code down to abort(); . Besides, if variable "a" is absent, bug is absent even with O3 optimization. So in simple case the optimizer takes into account the overflow, but misses it after a trivial change of the code. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1250883 Title: Optimizer's mistake To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/gcc-4.6/+bug/1250883/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs