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