[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / msan / chained_origin_memcpy.cc
blobe56db9c87d66ddc8fe5a5a6ca342fd1037a16f35
1 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -DOFFSET=0 -O3 %s -o %t && \
2 // RUN: not %run %t >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 < %t.out
5 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -m64 -O3 %s -o %t && \
6 // RUN: not %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 < %t.out
9 #include <stdio.h>
10 #include <string.h>
12 int xx[10000];
13 int yy[10000];
14 volatile int idx = 30;
16 __attribute__((noinline))
17 void fn_g(int a, int b) {
18 xx[idx] = a; xx[idx + 10] = b;
21 __attribute__((noinline))
22 void fn_f(int a, int b) {
23 fn_g(a, b);
26 __attribute__((noinline))
27 void fn_h() {
28 memcpy(&yy, &xx, sizeof(xx));
31 int main(int argc, char *argv[]) {
32 int volatile z1;
33 int volatile z2;
34 fn_f(z1, z2);
35 fn_h();
36 return yy[idx + OFFSET];
39 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
40 // CHECK: {{#0 .* in main .*chained_origin_memcpy.cc:36}}
42 // CHECK: Uninitialized value was stored to memory at
43 // CHECK: {{#1 .* in fn_h.*chained_origin_memcpy.cc:28}}
45 // CHECK: Uninitialized value was stored to memory at
46 // CHECK: {{#0 .* in fn_g.*chained_origin_memcpy.cc:18}}
47 // CHECK: {{#1 .* in fn_f.*chained_origin_memcpy.cc:23}}
49 // CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main'
50 // CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main'
51 // CHECK: {{#0 .* in main.*chained_origin_memcpy.cc:31}}