111
|
1 // { dg-do run }
|
|
2 extern "C" int printf(const char *, ...);
|
|
3 extern "C" const char *getenv(const char *);
|
|
4
|
|
5 class T {
|
|
6 int i;
|
|
7 public:
|
|
8 T() {
|
|
9 i = 1;
|
|
10 printf("T() at %x\n", this);
|
|
11 }
|
|
12 T(const T& o) {
|
|
13 i = o.i;
|
|
14 printf("T(const T&) at %x <-- %x\n", this, &o);
|
|
15 }
|
|
16 T operator +(const T& o) {
|
|
17 T r;
|
|
18 r.i = this->i + o.i;
|
|
19 return r;
|
|
20 }
|
|
21 operator int () {
|
|
22 return i;
|
|
23 }
|
|
24 ~T() { printf("~T() at %x\n", this); }
|
|
25 } s, b;
|
|
26
|
|
27 int foo() { return getenv("TEST") == 0; }
|
|
28
|
|
29 int main() {
|
|
30 int i = foo() ? s+b : s;
|
|
31 return i != 2;
|
|
32 }
|