Debian Codegraph @

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

raw
1 // { dg-do run }
2 // prms-id: 3579
3
4 extern "C" int printf(const char *, ...);
5
6 int num_x;
7
8 class Y {
9 public:
10 Y () { printf("Y() this: %x\n", this); }
11 ~Y () { printf("~Y() this: %x\n", this); }
12 };
13
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 }
22
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 }
28
29 ~X () { printf("~X() this: %x\n", this); --num_x; }
30 };
31
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;
40 }