1*97de0188SGui Andrade // RUN: %clangxx_msan -fexceptions -fsanitize-memory-track-origins=2 -latomic -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
2*97de0188SGui Andrade 
3*97de0188SGui Andrade // PPC has no libatomic
4*97de0188SGui Andrade // UNSUPPORTED: powerpc64-target-arch
5*97de0188SGui Andrade // UNSUPPORTED: powerpc64le-target-arch
6*97de0188SGui Andrade 
7*97de0188SGui Andrade #include <sanitizer/msan_interface.h>
8*97de0188SGui Andrade #include <stdatomic.h>
9*97de0188SGui Andrade 
10*97de0188SGui Andrade typedef struct __attribute((packed)) {
11*97de0188SGui Andrade   uint8_t val[3];
12*97de0188SGui Andrade } i24;
13*97de0188SGui Andrade 
14*97de0188SGui Andrade void copy(i24 *dst, i24 *src);
15*97de0188SGui Andrade 
main()16*97de0188SGui Andrade int main() {
17*97de0188SGui Andrade   i24 uninit;
18*97de0188SGui Andrade   i24 init = {0};
19*97de0188SGui Andrade 
20*97de0188SGui Andrade   __msan_check_mem_is_initialized(&init, 3);
21*97de0188SGui Andrade   copy(&init, &uninit);
22*97de0188SGui Andrade   __msan_check_mem_is_initialized(&init, 3);
23*97de0188SGui Andrade }
24*97de0188SGui Andrade 
copy(i24 * dst,i24 * src)25*97de0188SGui Andrade void copy(i24 *dst, i24 *src) {
26*97de0188SGui Andrade   try {
27*97de0188SGui Andrade     __atomic_load(src, dst, __ATOMIC_RELAXED);
28*97de0188SGui Andrade   } catch (...) {
29*97de0188SGui Andrade   }
30*97de0188SGui Andrade }
31*97de0188SGui Andrade 
32*97de0188SGui Andrade // CHECK: MemorySanitizer: use-of-uninitialized-value
33*97de0188SGui Andrade // CHECK: #0 {{0x[a-f0-9]+}} in main{{.*}}libatomic_load_exceptions.cpp:[[@LINE-11]]
34*97de0188SGui Andrade 
35*97de0188SGui Andrade // CHECK-SHADOW: Uninitialized value was stored to memory at
36*97de0188SGui Andrade // CHECK-SHADOW: #0 {{0x[a-f0-9]+}} in copy{{.*}}libatomic_load_exceptions.cpp:[[@LINE-9]]
37