[PR42542] g++ -O3 produces incorrect results for less-than operator
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc |
Fix Released
|
Medium
|
|||
gcc-4.3 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned | ||
gcc-4.4 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: g++-4.3
g++ appears to be (incorrectly) using a signed int comparison when -O3 optimization is enabled. Compiling with -O2 or lower produces the correct output.
This problem was observed on Ubuntu 9.04 x86_64. The source code (bug.cpp) is attached.
$ lsb_release -rd
Description: Ubuntu 9.04
Release: 9.04
$ uname -a
Linux rabota 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 22:12:12 UTC 2009 x86_64 GNU/Linux
$ apt-cache policy g++-4.3
g++-4.3:
Installed: 4.3.3-5ubuntu4
Candidate: 4.3.3-5ubuntu4
Version table:
*** 4.3.3-5ubuntu4 0
500 http://
100 /var/lib/
$ g++ --version
g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3
$ g++ -O2 bug.cpp && ./a.out
4264598888
$ g++ -O3 bug.cpp && ./a.out
1898580612
$ g++ -v -O3 bug.cpp
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
COLLECT_
/usr/lib/
ignoring nonexistent directory "/usr/local/
ignoring nonexistent directory "/usr/lib/
#include "..." search starts here:
#include <...> search starts here:
/usr/include/
/usr/include/
/usr/include/
/usr/local/include
/usr/lib/
/usr/lib/
/usr/include/
/usr/include
End of search list.
GNU C++ (Ubuntu 4.3.3-5ubuntu4) version 4.3.3 (x86_64-linux-gnu)
compiled by GNU C version 4.3.3, GMP version 4.2.4, MPFR version 2.4.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-
Compiler executable checksum: d9dd67dcc191271
COLLECT_
as -V -Qy -o /tmp/ccZsdHhv.o /tmp/cc1tnMId.s
GNU assembler version 2.19.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.19.1
COMPILER_
LIBRARY_
COLLECT_
/usr/lib/
Changed in gcc: | |
status: | Unknown → New |
summary: |
- g++ -O3 produces incorrect results for less-than operator + [PR42542] g++ -O3 produces incorrect results for less-than operator |
Changed in gcc-4.3 (Ubuntu): | |
status: | New → Triaged |
Changed in gcc: | |
status: | New → Confirmed |
Changed in gcc: | |
status: | Confirmed → Fix Released |
Changed in gcc: | |
importance: | Unknown → Medium |
it's a bug in your test case, result is overflowing. use `long' instead