1 // RUN: %clangxx_msan %s -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 %run %t >%t.out 2>&1
3 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 %run %t >%t.out 2>&1
5 // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 %run %t >%t.out 2>&1
7 #include <sanitizer/msan_interface.h>
14 // store value of subclass member
20 class Derived
: public Base
{
30 // ok access its own member
31 assert(__msan_test_shadow(&this->x_ptr
, sizeof(this->x_ptr
)) == -1);
32 // bad access subclass member
33 assert(__msan_test_shadow(this->x_ptr
, sizeof(*this->x_ptr
)) != -1);
37 // ok to access its own members
38 assert(__msan_test_shadow(&this->y
, sizeof(this->y
)) == -1);
39 // ok access base class members
40 assert(__msan_test_shadow(&this->x_ptr
, sizeof(this->x_ptr
)) == -1);
44 Derived
*d
= new Derived();
45 assert(__msan_test_shadow(&d
->x_ptr
, sizeof(d
->x_ptr
)) == -1);
47 assert(__msan_test_shadow(&d
->x_ptr
, sizeof(d
->x_ptr
)) != -1);