New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang::Sema::CheckForConstantInitializer(clang::Expr*, clang::QualType): Assertion `Init->containsErrors() && "Dependent code should only occur in error-recovery path."' failed. #50320
Comments
This problem is still reproducible on trunk Clang.
|
@llvm/issue-subscribers-bug |
@llvm/issue-subscribers-clang-frontend |
Confirmed: https://godbolt.org/z/3odYPn4Gn Assertion: clang++: /root/llvm-project/clang/lib/Sema/SemaDecl.cpp:12203:
bool clang::Sema::CheckForConstantInitializer(clang::Expr*, clang::QualType):
Assertion `Init->containsErrors() && "Dependent code should only occur in error-recovery path."' 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 -x c <source>
1. <source>:8:2: current parser token ';'
#0 0x000055cf14b3380f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x407280f)
#1 0x000055cf14b3154c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x407054c)
#2 0x000055cf14a7eef8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f62f96e0420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f62f91ad00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f62f918c859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f62f918c729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f62f919dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000055cf174fba7d clang::Sema::CheckForConstantInitializer(clang::Expr*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a3aa7d)
#9 0x000055cf17549388 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a88388)
#10 0x000055cf1721ae6e clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6759e6e)
#11 0x000055cf1722c2f8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x676b2f8)
#12 0x000055cf171f4d22 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6733d22)
#13 0x000055cf171f55cf clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#14 0x000055cf171fc0a9 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x673b0a9)
#15 0x000055cf171fc9fd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x673b9fd)
#16 0x000055cf171f089a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672f89a)
#17 0x000055cf15e94e98 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53d3e98)
#18 0x000055cf156fdbc9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c3cbc9)
#19 0x000055cf15681b56 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bc0b56)
#20 0x000055cf157e1507 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d20507)
#21 0x000055cf12027626 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1566626)
#22 0x000055cf1202313a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x000055cf154e8e9d 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
#24 0x000055cf14a7f3e0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fbe3e0)
#25 0x000055cf154e975f 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
#26 0x000055cf154b146c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49f046c)
#27 0x000055cf154b1f0d 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+++0x49f0f0d)
#28 0x000055cf154b9bdd clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49f8bdd)
#29 0x000055cf120259dc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x15649dc)
#30 0x000055cf11f32465 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1471465)
#31 0x00007f62f918e083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#32 0x000055cf1201dd6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x155cd6e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134 |
See also https://bugs.freebsd.org/272415 (it's pretty certain that's the same assertion failure). |
In here llvm-project/clang/lib/Sema/SemaDecl.cpp Lines 13324 to 13338 in b5a9f9f
we reset We can add a check here |
[clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer. Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++ code), we propagate the contains-errors bit for C-code path. Fixes llvm/llvm-project#50236 Fixes llvm/llvm-project#50243 Fixes llvm/llvm-project#48636 Fixes llvm/llvm-project#50320 Differential Revision: https://reviews.llvm.org/D154861 This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors() || RHSExpr->containsErrors()) && "Should only occur in error-recovery path."), function BuildBinOp') when building parts of dtrace in certain scenarios. Reported by: dstolfa PR: 271047 MFC after: 1 month
[clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer. Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++ code), we propagate the contains-errors bit for C-code path. Fixes llvm/llvm-project#50236 Fixes llvm/llvm-project#50243 Fixes llvm/llvm-project#48636 Fixes llvm/llvm-project#50320 Differential Revision: https://reviews.llvm.org/D154861 This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors() || RHSExpr->containsErrors()) && "Should only occur in error-recovery path."), function BuildBinOp') when building parts of dtrace in certain scenarios. Reported by: dstolfa PR: 271047 MFC after: 1 month (cherry picked from commit 8d0cab8)
[clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer. Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++ code), we propagate the contains-errors bit for C-code path. Fixes llvm/llvm-project#50236 Fixes llvm/llvm-project#50243 Fixes llvm/llvm-project#48636 Fixes llvm/llvm-project#50320 Differential Revision: https://reviews.llvm.org/D154861 This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors() || RHSExpr->containsErrors()) && "Should only occur in error-recovery path."), function BuildBinOp') when building parts of dtrace in certain scenarios. Reported by: dstolfa PR: 271047 MFC after: 1 month
Extended Description
$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 6b0d266)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64
$ cat mutant.c
$ clang-trunk -w mutant.c
mutant.c:3:10: error: cannot assign to variable 'b' with const-qualified type 'const int'
c[] = {b = a} static d = c
~ ^
mutant.c:2:7: note: variable 'b' declared const here
const b;
The text was updated successfully, but these errors were encountered: