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
6 
7 extern "C" int printf (const char *, ...);
8 extern "C" void exit (int);
9 
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);}
C()15   C() {
16     i = 1;
17   }
~C()18   ~C() {
19     if (i != 1) {
20       exit(1);
21     }
22     i = 0;
23   }
24 };
25 
26 C g;
27 
func()28 C func()  {
29   return g;
30 }
31 
main(int argc,char ** argv)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;
38 }
39