This testcase crashes when compiled with gcc 4.4 -m32 -msse -O2, but not when compiled with 4.3 or 4.5. It doesn't crash when compiled as -m64. /* compile me with -O2 -msse -m32 */ #include <string.h> typedef float v4sf __attribute__ ((vector_size (16)));
int main(void) { float m4[4]; v4sf m3; float m2[4] = {4, 3, 2, 1}; v4sf one2 = {5, 15, 25, 35}; memcpy(&m3, &m2, sizeof(m2)); m3 = m3 * one2; memcpy(&m4, &m3, sizeof(m4)); if (m4[0] != 20) return 1; return 0; } $ gcc-4.4 bug.c -m32 -O2 -msse $ ./a.out Segmentation fault GDB shows it crashes on the SSE instructions, probably wrong alignment: Dump of assembler code for function main: 0x080483a0 <+0>: push %ebp 0x080483a1 <+1>: mov %esp,%ebp 0x080483a3 <+3>: sub $0x14,%esp 0x080483a6 <+6>: movaps 0x80484d0,%xmm0 0x080483ad <+13>: movl $0x40800000,0x4(%esp) 0x080483b5 <+21>: movl $0x40400000,0x8(%esp) 0x080483bd <+29>: flds 0x80484e0 0x080483c3 <+35>: movl $0x40000000,0xc(%esp) 0x080483cb <+43>: movl $0x3f800000,0x10(%esp) => 0x080483d3 <+51>: mulps 0x4(%esp),%xmm0 0x080483d8 <+56>: movss %xmm0,(%esp) 0x080483dd <+61>: flds (%esp) 0x080483e0 <+64>: fucomip %st(1),%st 0x080483e2 <+66>: fstp %st(0) 0x080483e4 <+68>: setne %al 0x080483e7 <+71>: setp %dl 0x080483ea <+74>: or %edx,%eax 0x080483ec <+76>: movzbl %al,%eax 0x080483ef <+79>: leave 0x080483f0 <+80>: ret End of assembler dump. gcc -v output: Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.4-14' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.5 20100909 (prerelease) (Debian 4.4.4-14) My libc version is this (should it matter): GNU C Library (Debian EGLIBC 2.11.2-5) stable release version 2.11.2, by Roland McGrath et al. Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 4.4.5 20100824 (prerelease). Compiled on a Linux 2.6.32 system on 2010-09-03. Available extensions: crypt add-on version 2.1 by Michael Glad and others GNU Libidn by Simon Josefsson Native POSIX Threads Library by Ulrich Drepper et al BIND-8.2.3-T5B For bug reporting instructions, please see: <http://www.debian.org/Bugs/>. -- Summary: gcc-4.4: crash on vector code with -m32 -msse Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: edwintorok at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45678