2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / dyncast7.C
blob33e3fa787b92b64c8bb11bb4b1c87c62819f3527
1 // { dg-do run  }
2 // { dg-options "-fexceptions" }
4 #include <typeinfo>
5 #include <stdexcept>
7 class A {
8 public:
9   virtual void j () {}
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);
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   }