http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Bug ID: 58876 Summary: No non-virtual-dtor warning in std::unique_ptr Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yangzhe1990 at gmail dot com When compiling the following code #include <memory> struct A { virtual void f() = 0; }; struct B : public A { virtual void f() {}; }; int main() { std::unique_ptr<A> p(new B()); A *q = NULL; delete q; return 0; }; the compiler shows the following warning, test.cpp: In function ‘int main()’: test.cpp:14:9: warning: deleting object of abstract class type ‘A’ which has non-virtual destructor will cause undefined behaviour [-Wdelete-non-virtual-dtor] delete q; But a warning at the unique_ptr line is also expected.