Closed
Description
When attempting to compile below program with clang-17 small.c
, Clang triggers an assertion failure:
int (^a)() = ^() {
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 f05b58a):
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/536asbnff