2 //Lifetime of temporaries:
3 //egcs 2.92 performs cleanup for temporaries inside new expressions
4 //after the new is complete, not at the end of the full expression.
23 new_throws = ctor_throws = false;
24 new_done = ctor_done = func_done = dtor_done = delete_done = count = 0;
29 line_error(int i):line(i){}
32 #define CHECK(cond) if(!(cond))throw line_error(__LINE__);
41 CHECK(false); //no copy constructors in this code
46 A* addr(){return this;}
51 void* operator new(size_t s){
57 void operator delete(void *){
58 delete_done = ++count;
71 func(new B(A(10).addr()));
78 CHECK(delete_done==0);
86 func(new B(A(10).addr()));
93 CHECK(delete_done==0);
101 func(new B(A(10).addr()));
108 CHECK(delete_done==0);
117 }catch(line_error e){
118 printf("Got error in line %d\n",e.line);