aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p3579.C
blob: d960599450fefa2b86d0e151957af19b6562085d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// prms-id: 3579

extern "C" int printf(const char *, ...);

int num_x;

class Y {
public:
  Y () { printf("Y()            this: %x\n", this); }
  ~Y () { printf("~Y()           this: %x\n", this); }
};

class X {
public:
  X () {
    ++num_x;
    printf("X()            this: %x\n", this);
    Y y;
    *this = (X) y;
  }

  X (const Y & yy) { printf("X(const Y&)    this: %x\n", this); ++num_x; }
  X & operator = (const X & xx) {
    printf("X.op=(X&)      this: %x\n", this);
    return *this;
  }

  ~X () { printf("~X()           this: %x\n", this); --num_x; }
};

int main (int, char **) {
    { X anX; }
    if (num_x) {
      printf("FAIL\n");
      return 1;
    }
    printf("PASS\n");
    return 0;
};