------- Comment #7 from rguenth at gcc dot gnu dot org 2010-01-05 11:57 ------- Shorter testcase, fails at -O2 -fno-early-inlining:
extern void abort(void); typedef struct SEntry { int num; } TEntry; typedef struct STable { TEntry data[2]; } TTable; TTable * __attribute__((noinline)) init () { static TTable t; return &t; } static inline void inlined_wrong (TEntry *entry_p) { unsigned char index; entry_p->num = 0; for (index = 0; index < 1; index++) entry_p->num++; if (!entry_p->num) abort(); } void __attribute__((noinline)) expect_func (unsigned char *b) { if (!b) abort (); } int main () { unsigned char index = 0; TTable *table_p; expect_func (&index); table_p = init(); inlined_wrong (&(table_p->data[1])); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42614