gcc/testsuite/g++.dg/rtti/dyncast4.C
raw| 1 | // Test to make sure that we keep searching if we don't find the type we |
| 2 | // want at the expected address. |
| 3 | |
| 4 | // { dg-do run } |
| 5 | |
| 6 | struct A |
| 7 | { |
| 8 | virtual void f() {}; |
| 9 | }; |
| 10 | |
| 11 | struct B: A { }; |
| 12 | |
| 13 | struct C: A { }; |
| 14 | |
| 15 | struct D: B, C { }; |
| 16 | |
| 17 | int main() |
| 18 | { |
| 19 | D d; |
| 20 | A* ap = static_cast<B*>(&d); |
| 21 | C* cp = dynamic_cast<C*>(ap); |
| 22 | if (cp == 0) |
| 23 | return 1; |
| 24 | else |
| 25 | return 0; |
| 26 | } |