This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/16348] New: Loop gets executed when it shouldnt


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]