gcc/testsuite/g++.dg/ubsan/vptr-18.C
raw| 1 | // PR c++/98103 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | // { dg-additional-options "-fsanitize=vptr -fno-sanitize-recover=vptr" } |
| 4 | // Modified constexpr-dynamic17.C. |
| 5 | |
| 6 | struct V { |
| 7 | virtual void f(); |
| 8 | }; |
| 9 | |
| 10 | struct A : V { }; |
| 11 | |
| 12 | struct B : V { |
| 13 | constexpr B(V*, A*); |
| 14 | }; |
| 15 | |
| 16 | struct D : B, A { |
| 17 | constexpr D() : B((A*)this, this) { } |
| 18 | }; |
| 19 | |
| 20 | constexpr B::B(V* v, A* a) |
| 21 | { |
| 22 | dynamic_cast<B*>(a); // { dg-error "uninitialized" } |
| 23 | } |
| 24 | |
| 25 | constexpr D d; |