<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63103>63103</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Assertion failure with `continue` inside expression of for-statement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hazohelet
</td>
</tr>
</table>
<pre>
```c++
void test() {
for (;; ({ continue; })) {}
}
```
with analysis-based warning flags such as `-Wtautological-bitwise-compare`
Live demo: https://godbolt.org/z/c6coh8fnT
Assertion:
```
clang++: /root/llvm-project/clang/lib/Analysis/CFG.cpp:3550:
clang::CFGBlock* {anonymous}::CFGBuilder::VisitForStmt(clang::ForStmt*):
Assertion `Block == Succ' failed.
```
Backtrace:
```
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 -Wtautological-bitwise-compare <source>
1. <eof> parser at end of file
2. <source>:1:13: parsing function body 'test'
#0 0x00005647554298cf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c108cf)
#1 0x000056475542763c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c0e63c)
#2 0x0000564755370cb8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fab73349420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fab72e1600b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fab72df5859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fab72df5729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fab72e06fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x00005647588ce3e6 (anonymous namespace)::CFGBuilder::VisitForStmt(clang::ForStmt*) CFG.cpp:0:0
#9 0x00005647588d142d (anonymous namespace)::CFGBuilder::VisitCompoundStmt(clang::CompoundStmt*, bool) CFG.cpp:0:0
#10 0x00005647588d336c (anonymous namespace)::CFGBuilder::buildCFG(clang::Decl const*, clang::Stmt*) CFG.cpp:0:0
#11 0x00005647588d4b57 clang::CFG::buildCFG(clang::Decl const*, clang::Stmt*, clang::ASTContext*, clang::CFG::BuildOptions const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70bbb57)
#12 0x00005647588785b0 clang::AnalysisDeclContext::getCFG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x705f5b0)
#13 0x00005647587d4bd1 clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy, clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fbbbd1)
#14 0x0000564757cdbcc6 clang::Sema::PopFunctionScopeInfo(clang::sema::AnalysisBasedWarnings::Policy const*, clang::Decl const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64c2cc6)
#15 0x0000564757edb3bc clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66c23bc)
#16 0x0000564757c5875d clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x643f75d)
#17 0x0000564757b83491 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x636a491)
#18 0x0000564757baa360 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6391360)
#19 0x0000564757b76d31 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x635dd31)
#20 0x0000564757b775ef clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#21 0x0000564757b7df91 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6364f91)
#22 0x0000564757b7e906 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6365906)
#23 0x0000564757b7eda4 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6365da4)
#24 0x0000564757b7269a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x635969a)
#25 0x0000564756676738 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e5d738)
#26 0x0000564755ece8d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46b58d9)
#27 0x0000564755e52da6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4639da6)
#28 0x0000564755fb1476 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4798476)
#29 0x00005647528e711d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10ce11d)
#30 0x00005647528e2e1a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000564755cbad6d 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
#32 0x00005647553711c0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b581c0)
#33 0x0000564755cbb38f 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
#34 0x0000564755c82abc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4469abc)
#35 0x0000564755c8354d 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+++0x446a54d)
#36 0x0000564755c8b62d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447262d)
#37 0x00005647528e537a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10cc37a)
#38 0x00005647527ec1f5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xfd31f5)
#39 0x00007fab72df7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#40 0x00005647528ddbfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10c4bfe)
```
Note: GCC emits an error, while Clang does not.
GCC output:
```
<source>:2:16: error: continue statement not within a loop
2 | for (;; ({ continue; })) {
| ^~~~~~~~
```
Original issue that contained another crash: https://github.com/llvm/llvm-project/issues/63092
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z4yjW_jXkhlJKAn1e5MJx4n4zlXc720nNXLoQIJttCbSA8jEX-9u3kOQPFNudnolnq3a74i5bwOE5zzmcc0AQY8RKcn4FkmuQ3FyQzq6VvlqT39Wa19xelIq9XYE0HP4oQNfuL7wB4exZCQYtNxagHKACgmxsgBDCSmnonuNrgK_7b9k1pEpaITveP8puACo247KbYejuy2bK4eeLsGtIJKnfjDBBSQxn8IVoKeQKVjVZGWg6uobEQJCGwW-WdFbVaiUoqYNS2BdheEBV0xLNtzKH_-_FM4eMNwrgGVxb2xqAZwAtAFqsFCtVbS-VXgG0-B2gBU2pWueVfBrGzozh2gol3ZBDsGlN5GrkDM8gQAutlAVoUdfPTdBq9Q9O3c-x36IWJUCL2agnQIv54sslbVuAZzhJwu00Q388A3g2X3y5rhX9DtDMMUmkkm-N6oxjctuhEzXjevj9qzDCLpR-tI2z3J6o7cOZs8xmrq2Sjtp-KgjwDcA38LGjFKAMVkTUnF0eZOCa0O9WE8qPUfRwfzt7vIWmKxthIYFlt4Kat0pbaNXUIMKuu_KSqmak8D2TwpiOO-YgkQwKSeuOcWjXHFJNzBqWWzxoDlvNW60oN86djOr08NiNJMYoKojlDOpOQkO1aO2o4qMl9DtkXdNulQovQVg8aLXSpIFEr7qGS2tGm6u2t7FqWlFzHfDXtlaa643dA7Jh2ARWd_I7QItSyJ1bOPeBwYq9EF0FMQxWMFBOLmlbJ72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