<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/166848>166848</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang crashes when using a class that has `dllexport`ed virtual explicitly defaulted destructor and user-defined constructor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kikairoya
</td>
</tr>
</table>
<pre>
reproducer: https://godbolt.org/z/oT1e63436
version: clang HEAD
procedure: `clang --target=x86_64-win32 -fms-extensions test.cc`
(x86_64-mingw doesn't crash)
```
struct S {
__declspec(dllexport) virtual ~S() = default; //< using `{}` or dropping virtual doesn't crash
S() {} //< using `= default;` doesn't crash
};
S s;
```
```
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp:14519: void clang::Sema::DefineImplicitDestructor(clang::SourceLocation, clang::CXXDestructorDecl*): Assertion `(Destructor->isDefaulted() && !Destructor->doesThisDeclarationHaveABody() && !Destructor->isDeleted()) && "DefineImplicitDestructor - call it for implicit default dtor"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics --target=x86_64-win32 -fms-extensions <source>
1. <source>:4:2: current parser token ';'
2. <source>:1:1: parsing struct/union/class body 'S'
#0 0x000000000424be68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x424be68)
#1 0x0000000004249294 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4249294)
#2 0x000000000418d4f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f9b57e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f9b57e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007f9b57e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007f9b57e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007f9b57e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007f9b57e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000006e0d176 clang::Sema::DefineImplicitDestructor(clang::SourceLocation, clang::CXXDestructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e0d176)
#10 0x0000000006e0df8c clang::Sema::ActOnFinishCXXNonNestedClass() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e0df8c)
#11 0x00000000069ca29e clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69ca29e)
#12 0x00000000069cd060 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69cd060)
#13 0x000000000699fa5e clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x699fa5e)
#14 0x000000000695afa8 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x695afa8)
#15 0x000000000695b9df clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x695b9df)
#16 0x0000000006963293 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6963293)
#17 0x00000000069641a5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69641a5)
#18 0x0000000006964650 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6964650)
#19 0x0000000006945763 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6945763)
#20 0x0000000004b97858 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b97858)
#21 0x0000000004e85d25 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e85d25)
#22 0x0000000004e06bbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e06bbe)
#23 0x0000000004f7e57d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f7e57d)
#24 0x0000000000dd0d90 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdd0d90)
#25 0x0000000000dc790a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#26 0x0000000000dc7a8d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000000004c016d9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x000000000418d994 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x418d994)
#29 0x0000000004c01cef clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x0000000004bc2742 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bc2742)
#31 0x0000000004bc36ee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bc36ee)
#32 0x0000000004bcae45 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bcae45)
#33 0x0000000000dcd2b1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdcd2b1)
#34 0x0000000000c7c234 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc7c234)
#35 0x00007f9b57e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007f9b57e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000dc73a5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc73a5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWk1z2zjS_jXwBUUXCVL8OPjASNZM5s1MUpHrLd9UINiUsKYALgAq8h72t28BpEyRlj12ysphNxWXaaLRePrpRqMBgmrNNwLgBs0-odniirZmK9XNA3-gXMlHelXI8vFGQaNk2TJQKMzx1phGozBHZInIciPLQtbmWqoNIst_IbKUdwHEYRTGyM-Rn-9BaS6F7clqKjb499t8gfy8UZJB2SqwLSj2u0bPM1RtwKBwcUjjdRx5P7gICfaqnfbgYEBYZRob0OaaMRT7dhSS9sI7LjY_cClBC0QSg5mieotI1kGx0t1_P9dGtczgFUbJJ-TnGGO8XpfAat0AQyQt6xoOjVQGkQzvuTItrfG_V4ik9gUKF7iEira1QeEn3FGBwjluNRcba45VmyxQ7GOpcKlk09iGo6IJQtwjeFLvOp9VOxrYqp8a6-d23PBTZ_IK6_75xPbJn455RD7Z_9YXZKmkNIgs63q_8xol_wHs-CciSyNlrRFZ9t2WNS8QWa5gR_tfC2D1_P7-mjUNCvMgmgWZ1buXvOxCwAZPmLse7mkBFRfwedfUnHGzgM43UiGSnsrLVjH4Ihk1Np7I_FTZ_P5-6GcBIJJbv4c5zrUGZbs4_kg6yHkovOV60dEJ5ZF8EiMSY0SCsaQl-m5r5VlNlQPxO91D_kmWj3_T1Xaq4WmIkSh5yXrsYUbrGnODK6kw7wWO7selY4ggkuCK8hrKa-Tn377c5qtbrNtixw2muGg3WIGNY2zkdOpys22LayZ3g3MnLudat2CdjakoMResbkvAZgt93BaUPRhFGVh3NC5PMNAaSqydt-xr25NqLRmnBkqsWoE1U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