1 // RUN: %clang_cl_asan -Od %s -Fe%t
2 // RUN: %env_asan_opts=handle_sigfpe=1 not %run %t 2>&1 | FileCheck %s
3 
4 // Test the error output from misaligned SSE2 memory access. This is a READ
5 // memory access. Windows appears to always provide an address of -1 for these
6 // types of faults, and there doesn't seem to be a way to distinguish them from
7 // other types of access violations without disassembling.
8 
9 #include <emmintrin.h>
10 #include <stdio.h>
11 
test()12 __m128i test() {
13   char buffer[17] = {};
14   __m128i a = _mm_load_si128((__m128i *)buffer);
15   __m128i b = _mm_load_si128((__m128i *)(&buffer[0] + 1));
16   return _mm_or_si128(a, b);
17 }
18 
main()19 int main() {
20   puts("before alignment fault");
21   fflush(stdout);
22   volatile __m128i v = test();
23   return 0;
24 }
25 // CHECK: before alignment fault
26 // CHECK: ERROR: AddressSanitizer: access-violation on unknown address {{0x[fF]*}}
27 // CHECK-NEXT: The signal is caused by a READ memory access.
28 // CHECK-NEXT: #0 {{.*}} in test(void) {{.*}}misalignment.cpp:{{.*}}
29