<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - "destructor cannot be declared as a template" leads to segfault in Sema::LookupSpecialMember"
href="https://bugs.llvm.org/show_bug.cgi?id=38671">38671</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>"destructor cannot be declared as a template" leads to segfault in Sema::LookupSpecialMember
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>arthur.j.odwyer@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>cat >test.cc <<EOF
struct S {
template<class> ~S();
};
struct T : S {
~T() = default;
};
EOF
clang++ -std=c++11 -c test.cc
segfaults.
Partial stack trace:
4 libsystem_platform.dylib 0x000000000a876600 _sigtramp + 2173608176
5 clang-8 0x000000010992decd
clang::Sema::CheckCompletedCXXClass(clang::CXXRecordDecl*) + 10061
6 clang-8 0x0000000109934e91
clang::Sema::ActOnFinishCXXMemberSpecification(clang::Scope*,
clang::SourceLocation, clang::Decl*, clang::SourceLocation,
clang::SourceLocation, clang::ParsedAttributesView const&) + 465
7 clang-8 0x000000010953692c
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) + 1980
What's happening here is that when we emit err_destructor_template, we produce
a CXXRecordDecl with no destructor (because the destructor the user wrote was
invalid). Therefore, in Sema::LookupSpecialMember, `DD = RD->getDestructor()`
is nullptr; and then the call to `DD->isDeleted()` blows up.
I'm not sure what the appropriate fix is, but I think it would involve doing a
better fixup to `RD->getDestructor()` all the way back where we emit
err_destructor_template.</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>