<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111749>111749</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] Frontend Assertion Failure in clang::Sema::ActOnFinishCXXInClassMemberInitializer
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</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
struct { char a { b(tree->c * next) }
```
Tested version(s): 16.0.0 ~ 19.1.0, trunk.
Example: https://godbolt.org/z/vMM6ccs5c
Stack dump:
<details>
<summary>Click me</summary>
```
clang++: /root/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:4106: void clang::Sema::ActOnFinishCXXInClassMemberInitializer(clang::Decl*, clang::SourceLocation, clang::Expr*): Assertion `Init.isUsable() && "Init should at least have a RecoveryExpr"' 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:1: parsing struct/union/class body '(unnamed struct at <source>:1:1)'
#0 0x0000000003ba0208 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ba0208)
#1 0x0000000003b9decc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b9decc)
#2 0x0000000003aeb1f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000731c5f642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000731c5f6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000731c5f642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000731c5f6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000731c5f62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000731c5f639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000006a6da71 clang::Sema::ActOnFinishCXXInClassMemberInitializer(clang::Decl*, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a6da71)
#10 0x000000000664554d clang::Parser::ParseLexedMemberInitializer(clang::Parser::LateParsedMemberInitializer&) (.part.0) ParseCXXInlineMethods.cpp:0:0
#11 0x0000000006646a2d clang::Parser::ParseLexedMemberInitializers(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6646a2d)
#12 0x000000000669785b clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x669785b)
#13 0x0000000006699e93 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+++0x6699e93)
#14 0x000000000666e690 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+++0x666e690)
#15 0x000000000662b474 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x662b474)
#16 0x000000000662bede clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x662bede)
#17 0x0000000006633673 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6633673)
#18 0x000000000663455d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x663455d)
#19 0x0000000006634a00 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6634a00)
#20 0x0000000006626a42 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6626a42)
#21 0x00000000044f78b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44f78b8)
#22 0x00000000047b1719 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47b1719)
#23 0x000000000473005e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x473005e)
#24 0x0000000004896f9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4896f9e)
#25 0x0000000000cd7eff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd7eff)
#26 0x0000000000ccfc0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x000000000453b589 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 0x0000000003aeb6a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aeb6a4)
#29 0x000000000453bb7f 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 0x00000000045014bd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45014bd)
#31 0x00000000045025ad 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+++0x45025ad)
#32 0x0000000004509ed5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4509ed5)
#33 0x0000000000cd4dcf clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd4dcf)
#34 0x0000000000ba4884 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba4884)
#35 0x0000731c5f629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x0000731c5f629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000ccf6be _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccf6be)
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/eJzkWl1v2zrS_jXMDWFDoj4sXeTCdeJzet4ULU7yLnoXUNTI5kYitSSVOr3Y374gJSei7LjN2bhY7BZNYkucmWeeGQ5HFKnWfCMALlHyASVXF7QzW6kun55auChk-XT5O8dmCwoQWWFWU7FB5AMiHzBTVG9B40rJBlOBqdagDJcCV5TXnQIshZXElaxr-Y2LDebikda8xAa0wYxqQNESBVco8H-nQf-ftW1_RRvVMYPR4gNmW6owdR8LRDKjAGYoumYYkSUWsDOI5BgtriaqDq3cgTZQ4kdQmkuBSKYRyVG0xGE6D-YB_icO83k4D6zbRnXiYT6Wvt7Rpq0tfrw1ptXWEbJGZL2RZSFrM5dqg8j6OyLrx0-fUsZ0wsbyt4ayB1x2TTulIFqVYCivNYquny_prmmoekLR9arm7AE3gKIVIuuX60cJ7L-OgmbxIrJWUhpE1nX92MxaJf8OzH4dxq1rXiCyvoWGDn-ugNWrr1_nNh7RMg6D1Op5lLwcEiJaomjpBNynJTOfxZoLrrerr18_ilVNtf4ETQHqo-CG05p_B4VINpK2NhBZviRZr1N2isGNZNS4IHk3r3etciIubMvn9ENpYM3Muf5_TYsaEMlcUpAUkRQjQuxdrLeyq0tMDa6BaoO39BEwxX8Ck4-gnnrlBJGFS2coh_B_uble3l5j3RUNN5jiottgBa1UBhs5zQVutl0xZ7IZyD7knGvdgUZkjakoMRes7kpws8ZNL1xQ9mAUZW72tQpaJRloDSXWjhp72UpSrSXj1Ga06gTWTPHWzF_NtWCOgvyLkhtFG0zVpmtAGD1kh2xdNsim5TWoGezaWiobrz5DZs8TXc_cxEBkXXDxkkCuOsw25TeqqlmMZxs8k1YvbVurvTNtZ-YazxrLBZ7Ndlk6o7qZ6Sdh6A5FV1wYqPGsEnL2CKqQGux9PLvFs9mGsZmRsmZbygWKrk7itYO1oK3eSoNnFZO1VLOS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