1// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
2// RUN: MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s
3
4// Test that stack trace for the intermediate store is not empty.
5
6// CHECK: MemorySanitizer: use-of-uninitialized-value
7// CHECK: #0 {{.*}} in main
8
9// CHECK: Uninitialized value was stored to memory at
10// CHECK: #0 {{.*}} in fn_g
11// CHECK-NOT: #1
12
13// CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame
14// CHECK: #0 {{.*}} in main
15
16#include <stdio.h>
17
18volatile int x;
19
20__attribute__((noinline))
21void fn_g(int a) {
22 x = a;
23}
24
25__attribute__((noinline))
26void fn_f(int a) {
27 fn_g(a);
28}
29
30int main(int argc, char *argv[]) {
31 int volatile z;
32 fn_f(a: z);
33 return x;
34}
35

source code of compiler-rt/test/msan/chained_origin_empty_stack.cpp