http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36043
Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.j.odwyer at gmail dot com --- Comment #22 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> --- Here's another segfaulting test case, for x86-64. This fails with GCC 4.6.2 and GCC 4.8.1. This GCC bug is really hard to work around, since it can strike anywhere without warning. Is it possible that one of the patches above (e.g., Richard Biener's comment #9) could be adopted into 4.8.x or 4.9.x? #include <cstdio> #include <stdint.h> #include <sys/mman.h> struct int24_t { uint8_t m_Internal[3]; }; void foo(int24_t a) { puts("2"); } int main() { const int OS_PAGE_SIZE = 0x1000; const int COUNT = (OS_PAGE_SIZE) / sizeof(int24_t); printf("sizeof int24_t = %d\n", (int)sizeof(int24_t)); void* arena1 = mmap(0, OS_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); int24_t* ptr = (int24_t*)mmap(0, OS_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); munmap(arena1, OS_PAGE_SIZE); puts("1"); foo(ptr[COUNT-1]); puts("3"); }