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
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
) {
26 __attribute__((noinline
))
28 memcpy(&yy
, &xx
, sizeof(xx
));
31 int main(int argc
, char *argv
[]) {
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}}