Optimizer's mistake
Bug #1250883 reported by
Shkarnikov Sergey
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-4.6 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
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.
description: | updated |
To post a comment you must log in.