[Bug 1250883] [NEW] Optimizer's mistake
Shkarnikov Sergey
s.shkarnikov at samsung.com
Wed Nov 13 14:52:27 UTC 2013
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
Foundations Bugs, which is subscribed to gcc-4.6 in Ubuntu.
https://bugs.launchpad.net/bugs/1250883
Title:
Optimizer's mistake
Status in “gcc-4.6” package in Ubuntu:
New
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.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.6/+bug/1250883/+subscriptions
More information about the foundations-bugs
mailing list