FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / dyncast7.C
blobb1a55a43592cf04cc865e5b53677529eadb71825
1 // Special g++ Options: -fexceptions
3 #include <typeinfo>
4 #include <stdexcept>
6 class A {
7 public:
8   virtual void j () {}
9 };
11 class B : public A { };
12      
13 void x (A& a) {
14   // These should all work.
15   const B& b2 = dynamic_cast<B&>(a);
16   const B& b3 = dynamic_cast<const B&>((const A&)a);
17   const B& b4 = dynamic_cast<const B&>(a);
20 int main() {
21   try {
22     B b;
23     x (b);
24   } catch (std::exception& e) {
25     // If we get a bad_cast, it is wrong.
26     return 1;
27   }