<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63863>63863</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`clang-17`: Assertion `Init->containsErrors() && "Dependent code should only occur in error-recovery path."' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wierton
</td>
</tr>
</table>
<pre>
When attempting to compile below program with `clang-17 small.c`, Clang triggers an assertion failure:
```
int (^a)(int) = ^() {
return c;
};
```
The assertion failure message:
```
<source>:1:6: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them
1 | int (^a)(int) = ^() {
| ^
<source>:2:10: error: use of undeclared identifier 'c'
2 | return c;
| ^
<source>:1:17: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them
1 | int (^a)(int) = ^() {
| ^
clang: /root/llvm-project/clang/lib/Sema/SemaDecl.cpp:12319: bool clang::Sema::CheckForConstantInitializer(clang::Expr*, clang::QualType): Assertion `Init->containsErrors() && "Dependent code should only occur in error-recovery path."' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <source>:3:2: current parser token ';'
#0 0x0000558683e9ac1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a9ac1a)
#1 0x0000558683e9884c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a9884c)
#2 0x0000558683de7020 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007effcf348420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007effcee1500b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007effcedf4859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007effcedf4729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007effcee05fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x00005586864db20b clang::Sema::CheckForConstantInitializer(clang::Expr*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x60db20b)
#9 0x000055868651856a clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x611856a)
#10 0x000055868625bdaf clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e5bdaf)
#11 0x00005586862722b7 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e722b7)
#12 0x000055868623e728 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e3e728)
#13 0x000055868623f0a6 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.321) Parser.cpp:0:0
#14 0x000055868624394b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e4394b)
#15 0x0000558686245176 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e45176)
#16 0x000055868624549f clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e4549f)
#17 0x000055868623a1f3 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e3a1f3)
#18 0x0000558684f67560 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b67560)
#19 0x00005586848892e9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44892e9)
#20 0x000055868481dc42 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x441dc42)
#21 0x0000558684960c9f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4560c9f)
#22 0x0000558681622cc3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1222cc3)
#23 0x000055868161ade8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x00005586846912f9 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
#25 0x0000558683de74a5 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39e74a5)
#26 0x0000558684693eee clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4293eee)
#27 0x000055868466060b clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x426060b)
#28 0x00005586846611e3 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+0x42611e3)
#29 0x0000558684669fd6 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4269fd6)
#30 0x0000558681620a8e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1220a8e)
#31 0x0000558681551cb1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1151cb1)
#32 0x00007effcedf6083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x000055868161a4da _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x121a4da)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
Testing clang's version (commit f05b58a9468cc2990678e06bc51df56b30344807):
```
clang version 17.0.0 (https://github.com/llvm/llvm-project.git f05b58a9468cc2990678e06bc51df56b30344807)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
```
This assertion failure can be verified at https://gcc.godbolt.org/z/84oTK7W7q
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWt1z4ygS_2vIC2WXhL4f8uB14r3Zm6udm6RuH10IWjYXGbSA8rF__RVIdoTjeDO3nr3aOtd8SAJ1__rXTdMCqDFiIwGuUfYDym6uaG-3Sl8_CdBWyata8ZfrX7YgMbUWdp0VcoOtwkztOt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