summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init/call1.C
blob: d44b6dddc953db7c145f616fd0c821f53f0fcde9 (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
// Bug c++/16115
// { dg-options "-O2" }

extern "C" void abort(); 
 
int count = 0; 
 
struct T { 
    T() { count++; } 
    T(const T&) { count++; } 
    ~T() { if (count==0) abort(); --count; } 
}; 
 
struct auto_ptr { 
    T* p; 
 
    auto_ptr(T* __p) : p(__p) { } 
    ~auto_ptr() { delete p; } 
 
    T* release() { 
      T* t = p; 
      p = 0; 
      return t; 
    } 
}; 
 
void destroy (auto_ptr a) { 
  delete a.release(); 
} 
 
 
int main () 
{ 
  destroy (new T); 
}