OSDN Git Service

Index: cp/ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.mike / dyncast7.C
1 // { dg-do run  }
2 // { dg-options "-fexceptions" }
3
4 #include <typeinfo>
5 #include <stdexcept>
6
7 class A {
8 public:
9   virtual void j () {}
10 };
11
12 class B : public A { };
13      
14 void x (A& a) {
15   // These should all work.
16   const B& b2 = dynamic_cast<B&>(a);
17   const B& b3 = dynamic_cast<const B&>((const A&)a);
18   const B& b4 = dynamic_cast<const B&>(a);
19 }
20
21 int main() {
22   try {
23     B b;
24     x (b);
25   } catch (std::exception& e) {
26     // If we get a bad_cast, it is wrong.
27     return 1;
28   }
29 }