Skip to content

Instantly share code, notes, and snippets.

@serge-rgb
Last active February 1, 2020 22:54
Show Gist options
  • Save serge-rgb/e9e80ebe18e3cc902f83a214caa14891 to your computer and use it in GitHub Desktop.
Save serge-rgb/e9e80ebe18e3cc902f83a214caa14891 to your computer and use it in GitHub Desktop.
clang-cl.exe crash
#include <stdlib.h>
#include <intrin.h>
int
main()
{
__m128i var = {};
// Create an unaligned _m128i pointer.
__m128i* elem = (__m128i*) ( (char*)malloc(sizeof(__m128i) + 1) + 1 );
*elem = var; // Will crash on Windows 10 x64 with clang-cl.exe LLVM 9.0
/**
cl.exe generates (rax holds the elem pointer):
movdqa xmm0,xmmword ptr [var]
movdqu xmmword ptr [rax],xmm0
clang-cl.exe generates:
movdqa xmmword ptr [rax],xmm0
which traps, since movdqa requires memory destinations to be 16-byte aligned.
**/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment