<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112139>112139</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] Assertion `(data().DefaultedCopyAssignmentIsDeleted || needsOverloadResolutionForCopyAssignment()) && "copy assignment should not be deleted"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
**This testcase is generated by a fuzzer.**
Compiler Explorer: [https://godbolt.org/z/8n673vjre](https://godbolt.org/z/8n673vjre)
This invalid code will crash on Clang Assertion Trunk. It seems that this goes back to clang-11:
```cpp
struct C {
virtual ~C() = default;
C &operator=(const C& v = {}) = default;
};
struct D : C {};
```
Stack dump:
```
clang++: /root/llvm-project/clang/include/clang/AST/DeclCXX.h:922: void clang::CXXRecordDecl::setImplicitCopyAssignmentIsDeleted(): Assertion `(data().DefaultedCopyAssignmentIsDeleted || needsOverloadResolutionForCopyAssignment()) && "copy assignment should not be deleted"' 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++ -gdwarf-4 -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 <source>
1. <source>:5:16: current parser token ';'
2. <source>:5:1: parsing struct/union/class body 'D'
#0 0x0000000003baa6d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3baa6d8)
#1 0x0000000003ba839c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ba839c)
#2 0x0000000003af55f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007060f5642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007060f56969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007060f5642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007060f56287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007060f562871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007060f5639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000006b26a8d clang::Sema::DeclareImplicitCopyAssignment(clang::CXXRecordDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b26a8d)
#10 0x0000000006b26f6b clang::Sema::AddImplicitlyDeclaredMembersToClass(clang::CXXRecordDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b26f6b)
#11 0x00000000069cc814 clang::Sema::ActOnFields(clang::Scope*, clang::SourceLocation, clang::Decl*, llvm::ArrayRef<clang::Decl*>, clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributesView const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69cc814)
#12 0x0000000006b30d29 clang::Sema::ActOnFinishCXXMemberSpecification(clang::Scope*, clang::SourceLocation, clang::Decl*, clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributesView const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b30d29)
#13 0x00000000066b0a8d clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b0a8d)
#14 0x00000000066b3133 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+++0x66b3133)
#15 0x0000000006687930 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+++0x6687930)
#16 0x0000000006644e24 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6644e24)
#17 0x000000000664588e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664588e)
#18 0x000000000664d023 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664d023)
#19 0x000000000664df0d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664df0d)
#20 0x000000000664042a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664042a)
#21 0x0000000004502bd8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4502bd8)
#22 0x00000000047bc4d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47bc4d9)
#23 0x000000000473b07e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x473b07e)
#24 0x00000000048a204e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48a204e)
#25 0x0000000000cdb81f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdb81f)
#26 0x0000000000cd352a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x00000000045468a9 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 0x0000000003af5aa4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3af5aa4)
#29 0x0000000004546e9f 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 0x000000000450c7dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x450c7dd)
#31 0x000000000450d8cd 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+++0x450d8cd)
#32 0x00000000045151f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45151f5)
#33 0x0000000000cd86ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd86ef)
#34 0x0000000000ba7c44 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba7c44)
#35 0x00007060f5629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007060f5629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000cd2fde _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd2fde)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1v27jS_jXKDWFDomRJvsiFK8f7dt8uWjTBoncGRY5sbmRSh6RcZy_Obz8gJTum_LHNIu7B4hRpq1DD4TPPDGdGEonWfCUA7oPJh2AyvyOtWUt1_8L_ICLJk8ldKdnLfYBnAZ49rblGBrShRAPiGq1AgCIGGCpfEEFV--efoMadcBDOg7D_t5Cbhteg0MOuqaUCFcQzFEw-rI1pdBDPArwI8GIlWSlrM5ZqFeDFnwFe5CLN4u0fCoLJPMD5j4vj6fHyDjcXW1JzhqhkgL7zukZUEb1GUqCiJmKFZlqDMlwK9KRa8TxGHw3SABuNzJoYZKySlQSNSkKfkZGI2mmjKLKIutXSsPuhTdONaKNaalCBguxDN4LQlivTkhr9uwhwHuApCuI5YlCRtjZBfBArUIBT2Vh-pQpiaz-VQhtUBDhFWzfLas3ml3TYW_vrHsgcWeaL_cSD5B74MWuPxtrJ2k1zamD3qyMgwB_sj3UoXigpTYAXdb3djBol_wBqf-3lFlzQumVwNDJ7fArwYg60Lr59G6-DeDbF2OraSusqJxXPgnhWfPv2FahUzMp2QxrMx01Tc8pNIZuXmQvkDQjzUc-hBgOs49eqe_WtBY9zRgzp7o7nHWvALihBQVYEWYEEANOft6BqSdhX0LJurcKFVP7EflHrE5xaVwUYU9m8IHIQQXot25ohIQ0qAbE9WhzgDFWE18DGHcNfPj3MHh-QbssNN4igsl0hBY1UxgbgYD9ws27LMZWb3gOnjuBat6ADvEBEMNS7A5k19HvBRrZRhEKAC9QoaJSkoDUwpGWrumE7k2gtKXcbX7UCaap4Y8YXwyYcB-H0i5IrRTaIqFV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