<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/154713>154713</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] assertion failed on gcc.dg/pr70022.c
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Compiling the following test with assertion-enabled clang results in the assertion failure.
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/pr70022.c
Backtrace:
```console
clang: /root/llvm-project/llvm/include/llvm/ADT/APSInt.h:100: int64_t llvm::APSInt::getExtValue() const: Assertion `isRepresentableByInt64() && "Too many bits for int64_t"' 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 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
2. <source>:4:1: LLVM IR generation of declaration 'foo'
3. <source>:4:1: Generating code for declaration 'foo'
#0 0x0000000004039748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4039748)
#1 0x0000000004036b74 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4036b74)
#2 0x0000000003f7b288 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007ab2d7042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007ab2d70969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007ab2d7042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007ab2d70287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007ab2d702871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007ab2d7039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000004480863 llvm::APSInt::getExtValue() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4480863)
#10 0x00000000079632a0 (anonymous namespace)::LValueExprEvaluator::VisitArraySubscriptExpr(clang::ArraySubscriptExpr const*) ExprConstant.cpp:0:0
#11 0x0000000007973507 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::LValueExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#12 0x000000000797513d EvaluateLValue(clang::Expr const*, (anonymous namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool) ExprConstant.cpp:0:0
#13 0x000000000799725f (anonymous namespace)::IntExprEvaluator::VisitCastExpr(clang::CastExpr const*) ExprConstant.cpp:0:0
#14 0x0000000007959f6b clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#15 0x00000000079495e6 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#16 0x0000000007949d2b EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#17 0x000000000794eed8 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x794eed8)
#18 0x000000000794f0a1 clang::Expr::isEvaluatable(clang::ASTContext const&, clang::Expr::SideEffectsKind) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x794f0a1)
#19 0x00000000045098f2 clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45098f2)
#20 0x000000000451212e clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x451212e)
#21 0x000000000451a02c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x451a02c)
#22 0x000000000458148e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x458148e)
#23 0x00000000045930d4 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45930d4)
#24 0x00000000045fe66d clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45fe66d)
#25 0x00000000045f9634 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45f9634)
#26 0x00000000045fa570 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45fa570)
#27 0x00000000046048b3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#28 0x00000000049cb630 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#29 0x00000000049bab04 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49bab04)
#30 0x00000000066dcfb4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66dcfb4)
#31 0x00000000049c71a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49c71a8)
#32 0x0000000004cbbd85 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4cbbd85)
#33 0x0000000004c37f2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c37f2e)
#34 0x0000000004daddb1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4daddb1)
#35 0x0000000000db34ff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb34ff)
#36 0x0000000000daa1aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#37 0x0000000004a2f189 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
#38 0x0000000003f7b724 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f7b724)
#39 0x0000000004a2f79f 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
#40 0x00000000049f145d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49f145d)
#41 0x00000000049f24ee 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+0x49f24ee)
#42 0x00000000049fa125 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49fa125)
#43 0x0000000000daf9b5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdaf9b5)
#44 0x0000000000c637e4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc637e4)
#45 0x00007ab2d7029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x00007ab2d7029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x0000000000da9c55 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda9c55)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
This goes back to clang-20.1.0.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWl9v2z6y_TTKC2FDov4_5EFxkt78bn64RRz0PhqUNLK5oUiBpFLn2y9IyZYl20nddRcLbNEWFkUOzzkz5IwkEqXomgPcOuGdE97fkFZvhLx9mxEpxU91k4vy43Yh6oYyytdIbwBVgjHx016B0ugn1RtElAKpqeAz4CRnUKKCEb5GElTLtEKU26H7bqgilLUS5o6bbbRulONnDn508OOa6k2bzwtRm4uimNVUSiG7Cwc_5kzkDn6sidIwtBokqqUaupZ5uXbwYyNj18V4Xjhu5rjZHSnetCQFmLnczInc7m8huBIMHDezmB0_Qw5-lEJoBz8y9l7PGin-AcXu0sGPlBesLWFoyO5fzf_fl09czzeOn3muawxRrqNgpZHt5meOn3V9ut9r0A9b_YOwFhycODhFBou5ibK9Uk7kUvUCjQQFXBtx7z6ejNl-iIMjB0fIwfhVCFQT_oFyqhWqhNxN72Ds4NhqDqWR_PvzQ7Z8QKrNa6oRQXlrXNUIqZEW6BOH9HQnqlClWlAOfkS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