reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
// RUN: %clangxx -frtti -fsanitize=null,vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t
// RUN: not %run %t 2>&1 | FileCheck %s

// REQUIRES: cxxabi
// UNSUPPORTED: windows-msvc
// Nested crash reported
// UNSUPPORTED: freebsd

struct S { virtual int f() { return 0; } };
struct T : virtual S {};

struct Foo { virtual int f() { return 0; } };

int main(int argc, char **argv) {
  Foo foo;
  T *t = (T*)&foo;
  S *s = t;
  // 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'
  // CHECK-NEXT: [[PTR]]: note: object is of type 'Foo'
  return s->f();
}