2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p783b.C
blob0aacb3285af442e90eeb1b1bcbb9f029c0209978
1 // { dg-do run  }
2 // This one check for objects being destroyed twice.  The bug it is
3 // looking for is the extra dtor call on C() even though it is never
4 // built.
5 // prms-id: 783
7 extern "C" int printf (const char *, ...);
8 extern "C" void exit (int);
10 class C {
11   int i;
12 public:
13 //  C() {printf ("C ctor at %x\n", this);}
14 //  ~C() {printf ("C dtor at %x\n", this);}
15   C() {
16     i = 1;
17   }
18   ~C() {
19     if (i != 1) {
20       exit(1);
21     }
22     i = 0;
23   }
26 C g;
28 C func()  {
29   return g;
32 int main(int argc, char**argv) {
33   C c,d;
34 //  printf ("\n");
35   c = (argc != 1) ? C() : d;
36 //  printf ("\n");
37   return 0;