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.
Confirmed, it is broken in 20040628 also. Somehow the conditional is being removed.
It worked on 20040623 but not in 20040627.
the first generic dump is already borked: main () { int i; printf ("%d\n", 0); i = 0; <D1105>:; printf ("can not happen\n"); i = i + 1; goto <D1105>; } Could be up to the recent RTH work on genericization? It went in in the timeframe Pinksi isolated.
Subject: Bug 16348 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2004-07-04 17:28:56 Modified files: gcc : ChangeLog c-typeck.c Added files: gcc/testsuite/gcc.c-torture/execute: 20040704-1.c Log message: PR c/16348 * c-typeck.c (c_finish_loop): Don't clear cond for cond_is_first loops. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4284&r2=2.4285 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.335&r2=1.336 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040704-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.