1 // { dg-do run { xfail sparc64-*-elf arm-*-pe } } 2 // { dg-options "-fexceptions" } 3 // prms-id: 9706 4 5 #include <stdlib.h> 6 7 int count, acount; 8 operator new(size_t sz)9void *operator new(size_t sz) { ++count; return malloc (sz); } operator delete(void * p)10void operator delete(void *p) throw() { --count; free (p); } 11 12 class A { 13 public: A()14 A() { ++acount; } A(const A &)15 A(const A&) { ++acount; } ~A()16 ~A() { --acount; } 17 }; 18 main()19int main() { 20 int i; 21 22 // The standard library may have called new and/or delete during 23 // startup, so we have to reset the counter here. 24 count = 0; 25 26 for( i = 0; i < 10; i++ ) { 27 try { 28 throw A(); 29 } 30 catch (A& a) { 31 } 32 } 33 if (acount) 34 return 1; 35 if (count) 36 return 2; 37 } 38