https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61964
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work|4.7.4, 4.9.0 | Known to fail|4.8.3 | --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The testcase is violating strict-aliasing rules as you access a struct head as struct node here: if (n->prev == (void *)h) h->first = n->next; else n->prev->next = n->next; as n->prev points to &heads[0] while h is &heads[2] (an out-of-bound pointer). So n->prev is a struct head and you access a next field of a struct node of it. Changing k to 0 makes the testcase pass (now you don't run into the bogus path).