[Bug sanitizer/84508] Load of misaligned address using _mm_load_sd

noloader at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 22 03:19:00 GMT 2018


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

--- Comment #1 from Jeffrey Walton <noloader at gmail dot com> ---
__m128d is a tad bit cleaner. It does not require the casts.

$ cat test.c
#include <emmintrin.h>
int main(int argc, char* argv[])
{
  unsigned char t[16+1];
  __m128d x = _mm_load_sd((const double *)(t+1));
  _mm_store_pd((double*)t, 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 0x7ffd1cf2dd11 for type 'const double', which requires 8
byte alignment
0x7ffd1cf2dd11: note: pointer points here
 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00
00 00  c0 c8 e0 ba c4


More information about the Gcc-bugs mailing list