[llvm-bugs] [Bug 40894] New: Wdelete-abstract-non-virtual-dtor incorrect message/fixit in template

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 27 16:48:30 PST 2019


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

            Bug ID: 40894
           Summary: Wdelete-abstract-non-virtual-dtor incorrect
                    message/fixit in template
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: comexk at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

--

struct Foo {
    virtual void bar() = 0;
};

template <typename T>
void destroy(T *t) {
    t->~T();
}

void destroyFoo(Foo *foo) {
    destroy(foo);
}


--

Clang produces:

<source>:7:5: warning: destructor called on 'Foo' that is abstract but has
non-virtual destructor [-Wdelete-abstract-non-virtual-dtor]
    t->~T();
    ^
<source>:11:5: note: in instantiation of function template specialization
'destroy<Foo>' requested here
    destroy(foo);
    ^
<source>:7:9: note: qualify call to silence this warning
    t->~T();
        ^
        Foo::

The fixit suggests inserting the concrete type name (Foo::) inside the template
function, which doesn't make sense.  Interestingly, inserting T:: doesn't work
either; it's invalid syntax for whatever reason.

I'm not sure what the warning should do in this case, but as is, the fixit is
incorrect, and it's apparently impossible to "qualify call to silence this
warning" as the note says.

-- 
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/20190228/7bbb7735/attachment-0001.html>


More information about the llvm-bugs mailing list