https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84508

            Bug ID: 84508
           Summary: Load of misaligned address using _mm_load_sd
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: noloader at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

According to Intel
(https://software.intel.com/sites/landingpage/IntrinsicsGuide), there are no
alignment requirements for _mm_load_sd, _mm_store_sd and _mm_loaddup_pd. For
example, from _mm_load_sd:

  Description

    Load a double-precision (64-bit) floating-point element from
    memory into the lower of dst, and zero the upper element.
    mem_addr does not need to be aligned on any particular boundary.

$ gcc --version
gcc (Debian 6.3.0-18) 6.3.0 20170516

$ cat test.c
#include <emmintrin.h>
int main(int argc, char* argv[])
{
  unsigned char t[16+1];
  __m128i x =  _mm_castpd_si128(_mm_load_sd((const double *)(t+1)));
  _mm_store_pd((double*)t, _mm_castsi128_pd(x));
  return 0;
}

$ gcc -fsanitize=undefined test.c -o test.exe

$ ./test.exe
/usr/lib/gcc/x86_64-linux-gnu/6/include/emmintrin.h:140:10: runtime error: load
of misaligned address 0x7ffc768309b1 for type 'const double', which requires 8
byte alignment
0x7ffc768309b1: note: pointer points here
 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  b0 79 38 ee ca 7f
00 00  98 7e 38 ee ca
              ^

Reply via email to