<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - non-virtual destructor not detected with friend"
href="https://llvm.org/bugs/show_bug.cgi?id=25850">25850</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>non-virtual destructor not detected with friend
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andyg1001@hotmail.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code compiles "fine" with clang, but should really (in my
opinion) produce an error inside other::test() that the code is calling a
non-virtual destructor.
class base {
friend struct other;
public: virtual void fn();
protected: ~base();
};
class derived final : public base {
public: ~derived();
int data;
};
struct other {
void test() {
base* b = new derived();
delete b;
}
};
GCC produces a warning which is arguably too pro-active since it produces it
immediately on the declaration of derived. However, I feel it would be
advantageous/correct to trap the error at the point of use inside
other::test().
Side note: This bug report comes out of a recent discussion with David Blaikie
over LLVM commit r254592. That commit changed the base dtor to virtual to
silence the gcc warning. Note, of course, that there isn't an equivalent of
other::test() in the LLVM codebase (currently!) but I would feel happier about
rolling-back the commit to the non-virtual base dtor (and silence the gcc
warning) if I felt clang would correctly detect this corner case.
Is this reasonable?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>