// { dg-do assemble } template struct auto_ptr_ref { Y* py; auto_ptr_ref(Y* p) : py(p) {} }; template struct auto_ptr { X* px; public: typedef X element_type; explicit auto_ptr(X* p =0) throw() : px(p) {} auto_ptr(auto_ptr& r) throw() : px(r.release()) {} // { dg-message "note" } candidate template auto_ptr(auto_ptr& r) throw() : px(r.release()) {}// { dg-message "note" } candidate auto_ptr& operator=(auto_ptr& r) throw() { reset(r.release()); return *this; } template auto_ptr& operator=(auto_ptr& r) throw() { reset(r.release()); return *this; } ~auto_ptr() { delete px; } X& operator*() const throw() { return *px; } X* operator->() const throw() { return px; } X* get() const throw() { return px; } X* release() throw() { X* p=px; px=0; return p; } void reset(X* p=0) throw() { if (px != p) delete px, px = p; } auto_ptr(auto_ptr_ref r) throw() : px(r.py) {} // { dg-message "note" } template operator auto_ptr_ref() throw() { return auto_ptr_ref(release()); } template operator auto_ptr() throw() { return auto_ptr(release()); } }; struct Base { Base() {} virtual ~Base() {} }; struct Derived : Base { Derived() {} }; auto_ptr f() { auto_ptr null(0); return null; } void g(auto_ptr) { } void h(auto_ptr) { } // { dg-error "initializing" } int main() { auto_ptr x(f()); auto_ptr y(f()); x = y; g(f()); h(f()); // { dg-error "match" "match" } no usable copy ctor // { dg-message "candidate" "candidate note" { target *-*-* } 54 } }