http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52402
Bug #: 52402 Summary: IPA-SRA creates aligned loads from unaligned memory Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: rgue...@gcc.gnu.org CC: jamb...@gcc.gnu.org Target: x86_64-*-* The following segfaults at -O2 typedef int v4si __attribute__((vector_size(16))); struct T { v4si i[2]; int j; }; static v4si __attribute__((noinline)) foo (struct T t) { return t.i[0]; } static struct T *__attribute__((noinline)) init () { char *p = __builtin_malloc (sizeof (struct T) + 1); p++; __builtin_memset (p, 1, sizeof (struct T)); return (struct T *)p; } int main() { struct T *p; p = init (); if (foo (*p)[0] != 0x01010101) __builtin_abort (); return 0; } this is because ipa-prop.c:ipa_modify_call_arguments blindly loads from *p as if it were properly aligned.