[llvm-bugs] [Bug 38671] New: "destructor cannot be declared as a template" leads to segfault in Sema::LookupSpecialMember
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 22 10:27:37 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38671
Bug ID: 38671
Summary: "destructor cannot be declared as a template" leads to
segfault in Sema::LookupSpecialMember
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: arthur.j.odwyer at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
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.
--
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/20180822/70dc7ae4/attachment.html>
More information about the llvm-bugs
mailing list