Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/p9706.C

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