summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/torture/pr35164-2.C
blob: 463cad7f7b83f78377ec3fc2d2a15b69526cb894 (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
struct __shared_count {
    __shared_count() { _M_pi = new int; }
    int * _M_pi;
};
template<typename _Tp>
class __shared_ptr {
public:
    __shared_ptr(_Tp* __p);
    void reset(int * __p) {
        __shared_ptr(__p).swap(*this);
    }
    void swap(__shared_ptr<_Tp>& __other) {
        __other._M_refcount._M_pi = _M_refcount._M_pi;
    }
    __shared_count _M_refcount;
};
template<typename _Tp> class shared_ptr : public __shared_ptr<_Tp> {};
int main() {
    for (shared_ptr<int> *iter;;)
    {
        try {
            (iter++)->reset(new int);
        }
        catch (...) {
        }
    }
}