2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p3579.C
blob90a134446ad8b2065c1712f9dee248af358421d2
1 // { dg-do run  }
2 // prms-id: 3579
4 extern "C" int printf(const char *, ...);
6 int num_x;
8 class Y {
9 public:
10   Y () { printf("Y()            this: %x\n", this); }
11   ~Y () { printf("~Y()           this: %x\n", this); }
14 class X {
15 public:
16   X () {
17     ++num_x;
18     printf("X()            this: %x\n", this);
19     Y y;
20     *this = (X) y;
21   }
23   X (const Y & yy) { printf("X(const Y&)    this: %x\n", this); ++num_x; }
24   X & operator = (const X & xx) {
25     printf("X.op=(X&)      this: %x\n", this);
26     return *this;
27   }
29   ~X () { printf("~X()           this: %x\n", this); --num_x; }
32 int main (int, char **) {
33     { X anX; }
34     if (num_x) {
35       printf("FAIL\n");
36       return 1;
37     }
38     printf("PASS\n");
39     return 0;