https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65408
Bug ID: 65408 Summary: powerpc64 function argument passing may access invalid memory Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: uweigand at gcc dot gnu.org CC: amodra at gcc dot gnu.org, bergner at gcc dot gnu.org, meissner at gcc dot gnu.org Target: powerpc64-linux, powerpc64le-linux The following simple test case: struct test { int x; int y; int z; }; void func(struct test); void foo(struct test *ptr) { func(*ptr); } generates this code for "foo": ld 4,8(3) ld 3,0(3) bl func Note how *16 bytes* of memory are accessed here. This is wrong, since "struct test" is only 12 bytes in size with 4-byte alignment, and if you have an array of those, the last element may happen to reside just 12 bytes before a page boundary, so accessing 16 bytes may in fact crash. When using the -mstrict-align compiler option, we get instead: lwz 0,0(3) lwz 4,8(3) lwz 3,4(3) sldi 0,0,32 or 3,3,0 sldi 4,4,32 bl func which is less than optimal, but at least correct. This bug seems to be present in all compiler versions I've tested (BE or LE), modulo those that default to -mstrict-align (e.g. LE with -mtune=power7).