summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/vect/pr44861.cc
blob: 07c59a1382d1a410e92abcf57986278a19b0b05b (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
// { dg-do compile }

bool f();

struct counted_base {
    virtual void destroy() { }
    void release() { if (f()) destroy(); }
};

struct shared_count {
    shared_count() { }
    ~shared_count() { if (pi) pi->release(); }
    shared_count(shared_count& r) : pi(r.pi) { if (pi) pi->release(); }
    counted_base* pi;
};

struct Foo;

struct shared_ptr  {
    Foo& operator*() { return *ptr; }
    Foo* ptr;
    shared_count refcount;
};

struct Bar {
    Bar(Foo&, shared_ptr);
};

void g() {
    shared_ptr foo;
    new Bar(*foo, foo);
}

// { dg-final { cleanup-tree-dump "vect" } }