Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.old-deja / g++.other / temporary1.C
blobb1c8cd6517157751700d7cc86c46dedc2833090c
1 // { dg-do run  }
2 extern "C" int printf (const char *, ...);
4 int c, d;
5 class Foo 
7 public:
8    Foo() { printf("Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++c; }
9    Foo(Foo const &) { printf("Foo(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); }
10    ~Foo() { printf("~Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++d; }
13 // Bar creates constructs a temporary Foo() as a default
14 class Bar 
16 public:
17    Bar(Foo const & = Foo()) { printf("Bar(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); }
20 void fakeRef(Bar *)
24 int main() 
26    // Create array of Bar. Will use default argument on constructor.
27    // The old compiler will loop constructing Bar. Each loop will
28    // construct a temporary Foo() but will not destruct the Foo(). 
29    // The Foo() temporary is destructed only once after the loop 
30    // completes. This could lead to a memory leak if the constructor 
31    // of Foo() allocates memory.
32    Bar bar[2];
34    fakeRef(bar);
36    printf("Done\n");
38    if (c == d && c == 2)
39      return 0;
40    return 1;