1 // RUN: %clangxx_msan %s -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
2 // RUN: FileCheck %s < %t.out
4 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
5 // RUN: FileCheck %s < %t.out
7 // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
8 // RUN: FileCheck %s < %t.out
10 // RUN: %clangxx_msan %s -fsanitize=memory -fno-sanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
11 // RUN: FileCheck %s --check-prefix=CHECK-NO-FLAG < %t.out
13 // RUN: %clangxx_msan -fsanitize=memory -fsanitize-memory-use-after-dtor %s -o %t && MSAN_OPTIONS=poison_in_dtor=0 %run %t >%t.out 2>&1
14 // RUN: FileCheck %s --check-prefix=CHECK-NO-FLAG < %t.out
16 #include <sanitizer/msan_interface.h>
31 assert(sizeof(Simple
) <= sizeof(buf
));
33 // The placement new operator forces the object to be constructed in the
34 // memory location &buf. Since objects made in this way must be explicitly
35 // destroyed, there are no implicit calls inserted that would interfere with
37 Simple
*s
= new(&buf
) Simple();
40 if (__msan_test_shadow(s
, sizeof(*s
)) != -1)
41 printf("s is poisoned\n");
43 printf("s is not poisoned\n");
44 // CHECK: s is poisoned
45 // CHECK-NO-FLAG: s is not poisoned