1 // { dg-do run }
2 // { dg-shouldfail "ubsan" }
3 // { dg-options "-fsanitize=vptr -fno-sanitize-recover=undefined" }
4
fS5 struct S { virtual int f () { return 0; } };
6 struct T : virtual S {};
fU7 struct U { virtual int f () { return 0; } };
8
9 int
main()10 main ()
11 {
12 U u;
13 T *t = (T *) &u;
14 S *s = t;
15 return s->f ();
16 }
17
18 // { dg-output "\[^\n\r]*vptr-9.C:14:\[0-9]*: runtime error: cast to virtual base of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" }
19 // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" }
20 // { dg-output " ?.. .. .. .. ?.. .. .. .. ?.. .. .. .. \[^\n\r]*(\n|\r\n|\r)" }
21 // { dg-output " ?\\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" }
22 // { dg-output " ?vptr for 'U'" }
23