<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97230>97230</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang][C++] Class with no destructor because of error recovery crashes if a derived class is aggregate initialized
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MitalAshok
</td>
</tr>
</table>
<pre>
```c++
struct X {
~X() = defaul;
};
struct Y : X {} y1{};
```
https://godbolt.org/z/877vsf8jb
```
<source>:2:5: error: initializer on function does not look like a pure-specifier
2 | ~X() = defaul;
| ^ ~~~~~~
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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -O3 <source>
1. <source>:4:21: current parser token ';'
#0 0x0000000003a30b08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a30b08)
#1 0x0000000003a2e7ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a2e7ec)
#2 0x0000000003974058 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072549e042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000000007664c14 clang::Decl::AccessDeclContextCheck() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7664c14)
#5 0x0000000006583d21 clang::Sema::CheckDestructorAccess(clang::SourceLocation, clang::CXXDestructorDecl*, clang::PartialDiagnostic const&, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6583d21)
#6 0x0000000006b8d052 checkDestructorReference(clang::QualType, clang::SourceLocation, clang::Sema&) SemaInit.cpp:0:0
#7 0x0000000006bb2028 (anonymous namespace)::InitListChecker::CheckStructUnionTypes(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType, llvm::iterator_range<clang::CXXBaseSpecifier const*>, clang::DeclContext::specific_decl_iterator<clang::FieldDecl>, bool, unsigned int&, clang::InitListExpr*, unsigned int&, bool) SemaInit.cpp:0:0
#8 0x0000000006bb081d (anonymous namespace)::InitListChecker::CheckListElementTypes(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool, unsigned int&, clang::InitListExpr*, unsigned int&, bool) (.constprop.0) SemaInit.cpp:0:0
#9 0x0000000006b9f92a (anonymous namespace)::InitListChecker::CheckExplicitInitList(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, clang::InitListExpr*, bool) (.constprop.0) SemaInit.cpp:0:0
#10 0x0000000006ba032e (anonymous namespace)::InitListChecker::InitListChecker(clang::Sema&, clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool, bool, bool, llvm::SmallVectorImpl<clang::QualType>*) SemaInit.cpp:0:0
#11 0x0000000006ba240b clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ba240b)
#12 0x00000000067507b1 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67507b1)
#13 0x00000000063e345c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63e345c)
#14 0x00000000063f239a clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63f239a)
#15 0x00000000063b073e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b073e)
#16 0x00000000063b0f9e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b0f9e)
#17 0x00000000063b76c7 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b76c7)
#18 0x00000000063b85af clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b85af)
#19 0x00000000063abdaa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63abdaa)
#20 0x000000000431b9c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x431b9c8)
#21 0x00000000045a28d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45a28d9)
#22 0x000000000452869e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x452869e)
#23 0x000000000468ae0e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x468ae0e)
#24 0x0000000000c6f7b5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc6f7b5)
#25 0x0000000000c689da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x000000000435f159 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
#27 0x0000000003974504 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3974504)
#28 0x000000000435f74f 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
#29 0x0000000004325195 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4325195)
#30 0x0000000004325bfd 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+++0x4325bfd)
#31 0x000000000432d615 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x432d615)
#32 0x0000000000c6cb85 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc6cb85)
#33 0x0000000000b45704 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb45704)
#34 0x000072549e029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x000072549e029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x0000000000c6848e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc6848e)
```
This is a crash on invalid code.
Also a fixit for typos of `= delete`/`= default` rather than complaining that it doesn't look like `= 0` would be nice.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkms9zozgWx_8aclHZBQIMHHJw2_Fsz_ZU93ayW70nlxAPWxNZYiSRduYwf_uWBP4hbCfTXXEu60q3MejH93309PQQEK3ZSgDcBumHIJ3fkNaspbr9jRnCp3otH29KWT3fBpOw-6MB_mD_wnkQTrVRLTXoGwqy_gxCCP31LcB5gAsUxHNUQU1aHsT99SCb74_72v9FQTzt28jm6DnqDg5Vdl33P93_a2MaHcTTAC8CvFjJqpTcjKVaBXjxZ4AXeZY96Tr_vTyuNGwpnmnZKgpBfBfEUxzE09RKAaWksgdMMMMIZ3-CQlKguhXUMClQJUEjIQ3iUj4izh4BEdS0Cka6AcpqBupAA6Mgm73IBLmPLeW-07vuxF_u0xX58uluen-HdFtumEEEle0KKWikMshINIDBzLotx1RuArzg_Gn3NWqU_B2oCfCCad2CDvACEVEhJihvK0BmDYgqoteoJPTRKEIhwDPUKGiUpKA1VKgHhmeuJtFaUkYMVEi1AmmqWGPGneR7Q-gjqtpNY5W5U-E4CIsvSq4U2SCiVu0GhLHCUYAXsrHKqNw0jIMawbbhUoGy5zgRqxHRGpTFr0dGteIxwIuSid3lzivRaFV9J6oeJWi0QiNp2yVNY1tvTdOasUajjWWBRqNtPhkRvRnpZ2HINojnTBjgaHSPRqMVpSMjJadrwkQQz1-UZwtrQRq9lgaNaiq5VKOKkZWQ2jCq0agWcuTA-qe1qYJ43k8oHKLR5xh5PumgRRbawFUT666RBUdbpUAY1BClQSEjH0GgAGfWuXDW-1eA4xCF23D3iUkclmGOnHPE0yCe6mfdHXxRTBg3dA_d-OeHQop8X0ptFJBNgCfWB5gwzqeta7_JAAb4Q7jt5QW4OOiPfP0YMqDn9M84ENE2n8U9WwnCA5y3wgW4CnFpe7mCWifGU4s9tUWWhGmOZtYDvgKVT6CeO3n_IKLittO8J-mVmUlh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