summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/temp.C
blob: 0a5ce5812ecac659446cdc162c8b774625dcc18c (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
// { dg-do run  }
extern "C" int printf(const char *, ...);
extern "C" const char *getenv(const char *);

class T {
  int i;
public:
  T() {
    i = 1;
    printf("T() at %x\n", this);
  }
  T(const T& o) {
    i = o.i;
    printf("T(const T&) at %x <-- %x\n", this, &o);
  }
  T operator +(const T& o) {
    T r;
    r.i = this->i + o.i;
    return r;
  }
  operator int () {
    return i;
  }
  ~T() { printf("~T() at %x\n", this); }
} s, b;

int foo() { return getenv("TEST") == 0; }

int main() {
  int i = foo() ? s+b : s;
  return i != 2;
}