<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73112>73112</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: parsing segfault with wrongly formed requires nested expression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
iK4tsu
</td>
</tr>
</table>
<pre>
The following code fails to compile
```cpp
int main()
{
requires { requires (int; }
}
```
An example can be found [here](https://godbolt.org/z/axG5f4bf5)
A copy of the above stack trace:
```
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-17.0.1/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-13.2.0 -fcolor-diagnostics -fno-crash-diagnostics --std=c++20 <source> -isystem/opt/compiler-explorer/libs/entt/trunk/src
1. <unknown> parser at unknown location
2. <source>:3:1: parsing function body 'main'
3. <source>:3:1: in compound statement ('{}')
#0 0x0000000003349f18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3349f18)
#1 0x0000000003348044 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3348044)
#2 0x000000000329c028 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007faf20322420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x0000000007264b66 clang::Lexer::Lex(clang::Token&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x7264b66)
#5 0x00000000072ebd8f clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x72ebd8f)
#6 0x0000000007298fa8 clang::Preprocessor::CachingLex(clang::Token&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x7298fa8)
#7 0x00000000072ebd4b clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x72ebd4b)
#8 0x00000000058c1e7d clang::Parser::ConsumeAnyToken(bool) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58c1e7d)
#9 0x00000000059478f8 clang::Parser::ParseRequiresExpression() (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59478f8)
#10 0x0000000005928613 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x5928613)
#11 0x000000000592ac9a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x592ac9a)
#12 0x000000000592ae39 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x592ae39)
#13 0x000000000592f889 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x592f889)
#14 0x00000000059b3897 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59b3897)
#15 0x00000000059a998c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59a998c)
#16 0x00000000059aa342 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59aa342)
#17 0x00000000059ab149 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59ab149)
#18 0x00000000059ac40a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59ac40a)
#19 0x00000000058cabc8 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58cabc8)
#20 0x00000000058fcb79 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58fcb79)
#21 0x00000000058c5212 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58c5212)
#22 0x00000000058c632f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#23 0x00000000058cda8f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58cda8f)
#24 0x00000000058cef0a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58cef0a)
#25 0x00000000058cf470 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58cf470)
#26 0x00000000058be922 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58be922)
#27 0x00000000044f8b05 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x44f8b05)
#28 0x0000000003dd5f21 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3dd5f21)
#29 0x0000000003d5b9fb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3d5b9fb)
#30 0x0000000003eb5c23 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3eb5c23)
#31 0x0000000000bd50c5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xbd50c5)
#32 0x0000000000bce42d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#33 0x0000000003ba7489 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
#34 0x000000000329c453 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x329c453)
#35 0x0000000003ba76a9 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
#36 0x0000000003b6f477 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3b6f477)
#37 0x0000000003b6fe2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3b6fe2d)
#38 0x0000000003b79d0c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3b79d0c)
#39 0x0000000000bd2d31 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xbd2d31)
#40 0x0000000000acf511 main (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xacf511)
#41 0x00007faf1fdc6083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#42 0x0000000000bcdc2e _start (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xbcdc2e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWtGS2ygW_Rr1CyWXBLIlPfSD245nM9NbScVd--pCCNlsJNAA6nbv128BsluobSc7o8lma1NJLCPgnnO4XC4GrBTbc0rvg_lDMF_f4U4fhLxnvyVadXeFKF_vnw4UVKKuxQvje0BESUGFWa2AFoCIpmU1DaJ1EC2DReT-krZ1JYxr0GDGA5gFMO9rpQ_9Q5RL-nvHJFUgSB_A2xeYMa4D9ACCdH1qtB7ZOPVh_l9yQI-4aWsKCOagMHg7XoJg_nCgkgbzdQCzg9atCtAygJsAbvaiLEStZ0LuA7j5VwA3-PjLvEqKav6G1HUOiGhfgaiAPlCAC_FMgdKYfAVaYkJNj5eQfX78sNx-AKorGqYBBkW3B5K2Qmqj2wgM04eumBHRBHBT18-nj7CV4p-U6ABumFIdVQHcAMxLwDipu5JaRERidQAFJl8dHrgCraStFIQqRUugRCddsWmJlRKEYU1LIDsOFJGs1TMHeWtZlV3TnklFsyDKP0uxl7gBWO67hnJtgIMAbkRrkPUuIEN6bGshqTRlNeb7ME5n0SwO4KYwHuAKA_gQwAcQ7ssXLKswAeEehML0htvW9NnpttMzBcLGKADC8Jg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