<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112660>112660</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] Frontend assertion failure in clang::InitializationSequence::Perform
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yype
</td>
</tr>
</table>
<pre>
Hi there, clang++ crashes from an assertion failure on the following invalid test case:
```cpp
a ( [] < -> > { struct { struct {} b [( { }} c
```
Tested version(s): 17.0.1 ~ trunk (assertions)
Example: https://godbolt.org/z/TsM7341G3
<details>
<summary>Stack dump</summary>
```
clang++: /root/llvm-project/clang/lib/Sema/SemaInit.cpp:7663: clang::ExprResult clang::InitializationSequence::Perform(clang::Sema&, const clang::InitializedEntity&, const clang::InitializationKind&, clang::MultiExprArg, clang::QualType*): Assertion `Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast() || Kind.getKind() == InitializationKind::IK_DirectList' 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. <eof> parser at end of file
2. <source>:1:6: lambda expression parsing
3. <source>:1:16: in compound statement ('{}')
#0 0x0000000003bb1d58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb1d58)
#1 0x0000000003bafa1c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bafa1c)
#2 0x0000000003afcd68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072a27ea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072a27ea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000072a27ea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000072a27ea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000072a27ea2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000072a27ea39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000006eb709a 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+++0x6eb709a)
#10 0x0000000006acb90b BuildImplicitMemberInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::FieldDecl*, clang::IndirectFieldDecl*, clang::CXXCtorInitializer*&) (.constprop.0) SemaDeclCXX.cpp:0:0
#11 0x0000000006acc62c CollectFieldInitializer(clang::Sema&, (anonymous namespace)::BaseAndFieldInfo&, clang::FieldDecl*, clang::IndirectFieldDecl*) SemaDeclCXX.cpp:0:0
#12 0x0000000006b0227d clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b0227d)
#13 0x0000000006b570fa clang::Sema::DefineImplicitDefaultConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b570fa)
#14 0x00000000067e0f81 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67e0f81)
#15 0x0000000006ea6035 PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#16 0x0000000006eb4c3a 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+++0x6eb4c3a)
#17 0x0000000006a1a11b clang::Sema::ActOnUninitializedDecl(clang::Decl*) (.part.0) SemaDecl.cpp:0:0
#18 0x00000000066a00f8 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a00f8)
#19 0x00000000066afb19 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+++0x66afb19)
#20 0x00000000066b8437 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b8437)
#21 0x00000000066b88f9 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b88f9)
#22 0x0000000006764f72 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6764f72)
#23 0x0000000006765ca0 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6765ca0)
#24 0x0000000006766b75 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6766b75)
#25 0x00000000067060f2 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67060f2)
#26 0x00000000067071bb clang::Parser::ParseLambdaExpression() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67071bb)
#27 0x00000000066e6795 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e6795)
#28 0x00000000066e7147 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e7147)
#29 0x00000000066e71d9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e71d9)
#30 0x00000000066e753e clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::function_ref<void ()>, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e753e)
#31 0x00000000066a05b1 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a05b1)
#32 0x00000000066afb19 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+++0x66afb19)
#33 0x000000000666fb8e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x666fb8e)
#34 0x000000000667034e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x667034e)
#35 0x0000000006677ae3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6677ae3)
#36 0x00000000066789cd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66789cd)
#37 0x0000000006678e70 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6678e70)
#38 0x000000000666aeb2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x666aeb2)
#39 0x0000000004526408 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4526408)
#40 0x00000000047e0629 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47e0629)
#41 0x000000000475f1ae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x475f1ae)
#42 0x00000000048c5dce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c5dce)
#43 0x0000000000cdce6f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdce6f)
#44 0x0000000000cd4b7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#45 0x000000000456a119 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
#46 0x0000000003afd214 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3afd214)
#47 0x000000000456a70f 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
#48 0x000000000453000d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453000d)
#49 0x00000000045310fd 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+++0x45310fd)
#50 0x0000000004538a25 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4538a25)
#51 0x0000000000cd9d3f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd9d3f)
#52 0x0000000000ba9264 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba9264)
#53 0x000072a27ea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#54 0x000072a27ea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#55 0x0000000000cd462e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd462e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</details>
The test case was generated by a fuzzer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW0tz2zjy_zT0BSUVX-Lj4IMsWzOZSSr5x_7v5qYCyaaMDQhwANCRctjPvgWQlAjqYXvGys7uTiq2JbLR6P71A90ggaUkawZw7cxunNntFW7UIxfX220NVxkvttc_E6QeQYDjL1BOMVs7_o3j36BcYPkIEpWCVwgzhKUEoQhnqMSENgIQZ3okKjml_Btha0TYE6akQAqkQjmW4ARzx711XPt35Lb_87puryCMHD9BrYTICRZo4gR3yPzEN0gq0eRq9NGJb1FmhuiR8Q1y4lt9LR9Ncjj_A0gFBXoCIQlnjp9Ix0-dYI68eOpOPfRPpETDvmqRdjobkgGPuw2uaqr1Q49K1VIr6i8df7nmRcapmnKxdvzld8dfPsgPcRB6PwWWJMGiAIUJlU5wt7skm6rCYusEd_cK519R0VS1Eywcf7m_cxTJ9uvAelowx18KzpXjLyl9qia14P-AXH_t6JaUZI6_vIcKd3_eMaKm2irBPI6iQDNpaYO5E8zvNrX4DLKhanhVjyGYku9Y43QPvzXAcmjvfQJRclE5fjIY0M4XGXfjTB5nBsUdU0RtnyU0s_5KWNFT7mk-NFQRLfRc28K69X8Npg_bGhx_3tl-vvNuJ3I1v-kaVMs3cfwUOcGtE9yiI_O28vy6WvB6i5x44cQLZBgQebepKcmJWmCpej4DgtfOcEsE5Oo90cxiE4VQTFvTf3p_N7-_Q7LJKqIQRlmzRgJqLhRSfOyiRD022TTnVecahx5CpGxAOv4SYVYgwnLaFGCC3WQFlOH8qxI4N0mjFlALnoOUUCDJG9Fe1iOxlDwnWIebaBiSuSC16kQeunjnz-7UcdNPgq8FrhAW66YCpmTny7w2vsurmlAQE9jUlAsQvT9P9rE6MfHr-MuMsL27m6Q2WRffsCgnIZqs0YRrv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