This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21015] New: Bad loop optimization with -O2
- From: "phil at fifi dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Apr 2005 00:31:27 -0000
- Subject: [Bug c/21015] New: Bad loop optimization with -O2
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The enclosed program prints only "0" when compiled with -O2. It should print
"0" and "1". I've also tried 3.2.2 and the error is present.
Phil.
#include <stdio.h>
void
f(int start)
{
int i, end;
for (i = end = start; i <= end; ++i)
{
printf("%d\n", i);
if (i == start)
end = 1;
}
}
int
main()
{
f(0);
return 0;
}
--
Summary: Bad loop optimization with -O2
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: phil at fifi dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-redhat-linux-gnu
GCC host triplet: i686-redhat-linux-gnu
GCC target triplet: i686-redhat-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21015