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