1 // RUN: %clangxx_msan %s -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t
3 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t
5 // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t
7 #include <sanitizer/msan_interface.h>
10 // TODO: remove empty dtors when msan use-after-dtor poisons
11 // for trivial classes with undeclared dtors
15 // Packed into 4 bytes
18 // Force alignment to next 4 bytes
21 // Force alignment, 8 more bytes
49 Packed
*p
= new Packed();
51 for (int i
= 0; i
< 4; i
++)
52 assert(__msan_test_shadow(((char*)p
) + i
, sizeof(char)) != -1);
53 assert(__msan_test_shadow(&p
->d
, sizeof(double)) != -1);
54 assert(__msan_test_shadow(((char*)(&p
->d
)) + sizeof(double), sizeof(char)) !=
57 Empty
*e
= new Empty();
59 assert(__msan_test_shadow(e
, sizeof(*e
)) != -1);
61 Simple
*s
= new Simple();
63 assert(__msan_test_shadow(s
, sizeof(*s
)) != -1);
67 assert(__msan_test_shadow(a
, sizeof(*a
)) != -1);