1 // { dg-do run }
2 
3 struct ex;
4 struct basic {
5   int refcount;
6   ex eval() const;
basicbasic7   basic() : refcount(0) {}
8 };
9 
10 struct ex {
11   basic *bp;
exex12   ex() : bp(0) { }
13   ex(const basic &);
14   virtual ~ex();
15   void construct_from_basic(const basic &);
16 };
17 
eval()18 ex basic::eval() const {
19   throw 1;
20 }
21 
ex(const basic & b)22 inline ex::ex(const basic &b) { construct_from_basic (b); }
~ex()23 inline ex::~ex() { if (--bp->refcount == 0) delete bp; }
construct_from_basic(const basic & b)24 void ex::construct_from_basic(const basic &b) {
25   const ex & tmpex = b.eval();
26   bp = tmpex.bp;
27   bp->refcount++;
28 }
29 
pow()30 ex pow() { return basic(); }
31 
main()32 int main()
33 {
34   try { pow (); } catch (int) {}
35   return 0;
36 }
37