1// { dg-do compile } 2 3bool f(); 4 5struct counted_base { 6 virtual void destroy() { } 7 void release() { if (f()) destroy(); } 8}; 9 10struct shared_count { 11 shared_count() { } 12 ~shared_count() { if (pi) pi->release(); } 13 shared_count(shared_count& r) : pi(r.pi) { if (pi) pi->release(); } 14 counted_base* pi; 15}; 16 17struct Foo; 18 19struct shared_ptr { 20 Foo& operator*() { return *ptr; } 21 Foo* ptr; 22 shared_count refcount; 23}; 24 25struct Bar { 26 Bar(Foo&, shared_ptr); 27}; 28 29void g() { 30 shared_ptr foo; 31 new Bar(*foo, foo); 32} 33 34// { dg-final { cleanup-tree-dump "vect" } } 35