| 1 |
// PR c++/70035 |
| 2 |
// { dg-do run } |
| 3 |
// { dg-shouldfail "ubsan" } |
| 4 |
// { dg-options "-fsanitize=vptr -fno-sanitize-recover=undefined -fno-implicit-constexpr" } |
| 5 |
|
| 6 |
struct A { |
| 7 |
A (int) {} |
| 8 |
virtual int foo () { return 1; } |
| 9 |
}; |
| 10 |
struct B : public A { |
| 11 |
using A::foo; |
| 12 |
B (int x) : A (foo (x)) {} |
| 13 |
int foo (int x) { return x * 2; } |
| 14 |
}; |
| 15 |
|
| 16 |
int |
| 17 |
main () |
| 18 |
{ |
| 19 |
B b (20); |
| 20 |
} |
| 21 |
|
| 22 |
// { dg-output "\[^\n\r]*pr70035.C:12:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'B'(\n|\r\n|\r)" } |
| 23 |
// { dg-output "0x\[0-9a-fA-F]*: note: object has invalid vptr(\n|\r\n|\r)" } |
| 24 |
// { dg-output " ?.. .. .. .. ?.. .. .. .. ?.. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } |
| 25 |
// { dg-output " ?\\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } |
| 26 |
// { dg-output " ?invalid vptr" } |