This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33611] New: Optimizations generate incorrect code
- From: "macracan at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Oct 2007 17:02:33 -0000
- Subject: [Bug c++/33611] New: Optimizations generate incorrect code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following snipped when compiled with -O0 generates a program that quickly
finishes (correct behavior). But when compiled with any optimizations (-O1, -O2
or -O3) generates a program that never finishes. Variations on the code, (such
as the comment line) geneate valid program with either level of optimization.
Checked in 4.1.1 too (i386) and the bug is there too. Checked in 4.1.2 on
x86_64 and the bug is NOT there.
-- star of file aa.cpp
struct A
{
unsigned int e;
};
A a = {1};
double f[] = {0.0461109, 0.285433};
int main(void)
{
for (bool bEncore = true; bEncore; )
{
bEncore = false;
double p = 0.422244 * f[a.e];
// double p = 0.422244 * f[1];
if (f[0] < p)
{
f[0] = p;
bEncore = true;
}
}
return 0;
}
-- end of file aa.cpp
g++ -O3 aa.cpp
./a.out --> goes into infinite loop
--
Summary: Optimizations generate incorrect code
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: macracan at yahoo dot com
GCC build triplet: GNU/linux i386/i686
GCC host triplet: GNU/linux i386/i686
GCC target triplet: GNU/linux i386/i686
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33611