blob: 9821f22273f77349375ac8fff1559259925209d0 [file] [log] [blame]
// RUN: %clangxx -frtti -fsanitize=null,vptr -g %s -O3 -o %t
// RUN: %run %t 2>&1 | FileCheck %s
// REQUIRES: cxxabi
#include <string.h>
class Base {
public:
int i;
virtual void print() {}
};
class Derived : public Base {
public:
void print() {}
};
int main() {
char *c = new char[sizeof(Derived)];
memset((void *)c, 0, sizeof(Derived));
Derived *list = (Derived *)c;
// CHECK: PR33221.cpp:[[@LINE+2]]:19: runtime error: member access within address {{.*}} which does not point to an object of type 'Base'
// CHECK-NEXT: invalid vptr
int foo = list->i;
return 0;
}