blob: cb6c6ea775b7d0f0da03dd5539997bf9ba52c84e [file] [log] [blame]
// { dg-do run }
// { dg-shouldfail "ubsan" }
// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" }
extern "C" void abort ();
struct S { virtual void f () {} };
struct T : S { ~T (); };
struct U : S { };
struct V : T, virtual U {};
U *up;
V *vp;
int
main ()
{
V v;
up = vp = &v;
}
T::~T ()
{
if (vp != up)
abort ();
}
// { dg-output "\[^\n\r]*vptr-8.C:24:\[0-9]*: runtime error: cast to virtual base of address 0x\[0-9a-fA-F]* which does not point to an object of type 'V'(\n|\r\n|\r)" }
// { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'T'(\n|\r\n|\r)" }
// { dg-output " ?.. .. .. .. ?.. .. .. .. ?.. .. .. .. \[^\n\r]*(\n|\r\n|\r)" }
// { dg-output " ?\\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" }
// { dg-output " ?vptr for 'T'" }