This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30245] New: -O2 generates bad code
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Dec 2006 09:34:02 -0000
- Subject: [Bug c++/30245] New: -O2 generates bad code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I compiled the following C++ code on a x86_64 machine
without optimisation.
#include <iostream.h>
int
main()
{
long long n = 1;
cout << sizeof( n) << endl;
for (int i = 0; i < 100; ++i)
{
cout << n << ' ' << (float) n << '\n';
n *= 2;
if (n == 0)
{
break;
}
}
return 0;
}
When the compiled code runs, it is fine.
There are 64 executions of the loop.
However, I added flag -O2, and the code runs differently.
There are 100 executions of the loop.
Suspect optimiser bug.
--
Summary: -O2 generates bad code
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dcb314 at hotmail dot com
GCC host triplet: x86_64-pc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30245