http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49001
Summary: GCC uses VMOVAPS/PD AVX instructions to access stack variables that are not 32-byte aligned Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: npo...@quick.cz I'm using a custom mingw64 build of GCC 4.6.1. My target is Windows 64bit. I compile with g++ -03 -march=corei7-avx -mtune=corei7-avx -mavx. GCC uses aligned moves VMOVAPS/PD from the new AVX instruction set to access local variables of type __m256/__m256d on the stack. But the stack pointer is only 16byte aligned on Win64, so this causes a segmentation fault error when the stack pointer is not 32byte aligned, as in: __m256 dummy_ps256; void test_stackalign32() { __m256 x = dummy_ps256; dummy_ps256 = sin256_ps_avx(x); } which compiles to vmovaps dummy_ps256(%rip), %ymm0 leaq 32(%rsp), %rdx vmovaps %ymm0, 32(%rsp) // possible SEGFAULT leaq 64(%rsp), %rcx vzeroupper call _Z13sin256_ps_avxDv8_f vmovaps 64(%rsp), %ymm0 // possible SEGFAULT I couldn't figure out how to realign a stack with -mstackrealign.