[LLVMbugs] [Bug 7966] New: missing warning about use of virtual member inside destructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Aug 22 15:07:11 PDT 2010


           Summary: missing warning about use of virtual member inside
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nicholas at mxc.ca
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

This small program is dangerous:

  struct Base {
    virtual ~Base() {
    virtual int test() = 0;
  struct Derived : public Base {
    int test() { return 0; }

because the destructor will be called after Derived is destroyed and the lookup
for test will always call the pure virtual method. G++ kindly emits a warning

$ g++ -fsyntax-only vd.cpp
vd.cpp: In destructor ‘virtual Base::~Base()’:
vd.cpp:3: warning: abstract virtual ‘virtual int Base::test()’ called from

but Clang doesn't. We really should!

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list