1 //Lifetime of temporaries:
2 //egcs 2.92 performs cleanup for temporaries inside new expressions
3 //after the new is complete, not at the end of the full expression.
22 new_throws = ctor_throws = false;
23 new_done = ctor_done = func_done = dtor_done = delete_done = count = 0;
28 line_error(int i):line(i){}
31 #define CHECK(cond) if(!(cond))throw line_error(__LINE__);
40 CHECK(false); //no copy constructors in this code
45 A* addr(){return this;}
50 void* operator new(size_t s){
56 void operator delete(void *){
57 delete_done = ++count;
70 func(new B(A(10).addr()));
77 CHECK(delete_done==0);
85 func(new B(A(10).addr()));
92 CHECK(delete_done==0);
100 func(new B(A(10).addr()));
107 CHECK(delete_done==3);
116 }catch(line_error e){
117 printf("Got error in line %d\n",e.line);