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: target={{.*windows-msvc.*}} |
7 | // Nested crash reported |
8 | // UNSUPPORTED: target={{.*freebsd.*}} |
9 | // FIXME: Itanium demangling isn't done for the type names on MinGW targets. |
10 | // XFAIL: target={{.*windows-gnu.*}} |
11 | |
12 | struct S { virtual int f() { return 0; } }; |
13 | struct T : virtual S {}; |
14 | |
15 | struct Foo { virtual int f() { return 0; } }; |
16 | |
17 | int main(int argc, char **argv) { |
18 | Foo foo; |
19 | T *t = (T*)&foo; |
20 | S *s = t; |
21 | // 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' |
22 | // CHECK-NEXT: [[PTR]]: note: object is of type 'Foo' |
23 | return s->f(); |
24 | } |
25 | |