| 1 |
// { dg-do run } |
| 2 |
// { dg-shouldfail "ubsan" } |
| 3 |
// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" } |
| 4 |
|
| 5 |
extern "C" void abort (); |
| 6 |
|
| 7 |
struct S { virtual void f () {} }; |
| 8 |
struct T : S { ~T (); }; |
| 9 |
struct U : S { }; |
| 10 |
struct V : T, virtual U {}; |
| 11 |
|
| 12 |
U *up; |
| 13 |
V *vp; |
| 14 |
|
| 15 |
int |
| 16 |
main () |
| 17 |
{ |
| 18 |
V v; |
| 19 |
up = vp = &v; |
| 20 |
} |
| 21 |
|
| 22 |
T::~T () |
| 23 |
{ |
| 24 |
if (vp != up) |
| 25 |
abort (); |
| 26 |
} |
| 27 |
|
| 28 |
// { 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)" } |
| 29 |
// { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'T'(\n|\r\n|\r)" } |
| 30 |
// { dg-output " ?.. .. .. .. ?.. .. .. .. ?.. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } |
| 31 |
// { dg-output " ?\\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } |
| 32 |
// { dg-output " ?vptr for 'T'" } |