1 // RUN: %clangxx -frtti -fsanitize=null,vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3
4 // REQUIRES: shared_cxxabi
5 // REQUIRES: cxxabi
6 // UNSUPPORTED: windows-msvc
7 // Nested crash reported
8 // UNSUPPORTED: freebsd
9
fS10 struct S { virtual int f() { return 0; } };
11 struct T : virtual S {};
12
fFoo13 struct Foo { virtual int f() { return 0; } };
14
main(int argc,char ** argv)15 int main(int argc, char **argv) {
16 Foo foo;
17 T *t = (T*)&foo;
18 S *s = t;
19 // CHECK: vptr-virtual-base.cpp:[[@LINE-1]]:10: runtime error: cast to virtual base of address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
20 // CHECK-NEXT: [[PTR]]: note: object is of type 'Foo'
21 return s->f();
22 }
23