[llvm-bugs] [Bug 28460] New: Wdelete-non-virtual-dtor doesn't work with std::unique_ptr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 7 10:43:19 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28460

            Bug ID: 28460
           Summary: Wdelete-non-virtual-dtor doesn't work with
                    std::unique_ptr
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

This warns, like it should:

thakis at thakis:~/src/chrome/src$ cat test.cc
#include <memory>

struct S {
  virtual void f() {}
};

struct T : public S {
};

void f(S* s) {
  delete s;
}
thakis at thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c test.cc -Wall -std=c++11 
test.cc:11:3: warning: delete called on non-final 'S' that has virtual
functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
  delete s;
  ^
1 warning generated.



But this doesn't:

thakis at thakis:~/src/chrome/src$ cat test.cc
#include <memory>

struct S {
  virtual void f() {}
};

struct T : public S {
};

void f() {
  std::unique_ptr<S> s;
}
thakis at thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c test.cc -Wall -std=c++11 


It should.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160707/b07ffbdf/attachment.html>


More information about the llvm-bugs mailing list