https://llvm.org/bugs/show_bug.cgi?id=26137
Bug ID: 26137 Summary: Warn when manual invoking a non-virtual destructor of a class with virtual methods Product: clang Version: unspecified Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: dch...@google.com CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified Clang already has a warning (-Wdelete-non-virtual-dtor) when deleting a class with virtual functions but a non-virtual destructor. However, this warning doesn't trigger when the destructor is manually invoked: $ cat test.cc #include <stdio.h> #include <new> struct B { ~B() { puts("Destroying B"); } virtual void f() = 0; }; struct D : public B { ~D() { puts("Destroying D"); } void f() override { } }; int main() { char buffer[sizeof(D)]; B* b = new (buffer) D; b->~B(); // No warning. B* b2 = new D; delete b2; // Warning. } $ clang++ -Wall -std=c++11 test.cc test.cc:20:3: warning: delete called on 'B' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor] delete b2; // Warning. ^ 1 warning generated. This has already resulted in at least one real bug in Chrome: https://crbug.com/577478. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs