This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16348] New: Loop gets executed when it shouldnt
- From: "anton at samba dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jul 2004 14:51:20 -0000
- Subject: [Bug c/16348] New: Loop gets executed when it shouldnt
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I compiled a 3.5 powerpc64 toolchain from cvs (20040703) and found an issue
when booting a linux kernel compiled with it. Here is a simplified test case:
struct foo {
long *a;
} bar[0];
#define SIZE (sizeof(bar)/sizeof(*bar))
int main()
{
int i;
printf("%d\n", SIZE);
for (i = 0; i < SIZE; i++)
printf("can not happen\n");
}
When compiled with no optimisation, the loop is executed even though size is 0:
0
can not happen
can not happen
can not happen
etc.
--
Summary: Loop gets executed when it shouldnt
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anton at samba dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16348