2 // { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } }
3 //Lifetime of temporaries:
4 //egcs 2.92 performs cleanup for temporaries inside new expressions
5 //after the new is complete, not at the end of the full expression.
24 new_throws = ctor_throws = false;
25 new_done = ctor_done = func_done = dtor_done = delete_done = count = 0;
30 line_error(int i):line(i){}
33 #define CHECK(cond) if(!(cond))throw line_error(__LINE__);
42 CHECK(false); //no copy constructors in this code
47 A* addr(){return this;}
52 void* operator new(size_t s){
58 void operator delete(void *){
59 delete_done = ++count;
72 func(new B(A(10).addr()));
79 CHECK(delete_done==0);
87 func(new B(A(10).addr()));
94 CHECK(delete_done==0);
102 func(new B(A(10).addr()));
109 CHECK(delete_done==3);
118 }catch(line_error e){
119 printf("Got error in line %d\n",e.line);