<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/155147>155147</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][bytecode] Assertion `!ItemTypes.empty()' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
crash-on-invalid,
clang:bytecode
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Reproducer:
https://godbolt.org/z/3o9Mdohve
```c
int foo(x)
int x;
{
return x;
}
void bar() {
int x;
x = foo();
}
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ByteCode/InterpStack.h:51: void clang::interp::InterpStack::discard() [with T = clang::interp::Integral<32, true>]: Assertion `!ItemTypes.empty()' 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 -x c -fexperimental-new-constant-interpreter <source>
1. <source>:10:1: current parser token '}'
2. <source>:7:12: parsing function body 'bar'
3. <source>:7:12: in compound statement ('{}')
#0 0x0000000004047f38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4047f38)
#1 0x0000000004045364 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4045364)
#2 0x0000000003f89a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000079af81c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000079af81c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000079af81c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000079af81c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000079af81c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000079af81c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007b7a4a2 clang::interp::cleanupAfterFunctionCall(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Function const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b7a4a2)
#10 0x0000000007bd4bae clang::interp::Call(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Function const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bd4bae)
#11 0x0000000007e68812 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCallExpr(clang::CallExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e68812)
#12 0x0000000007e6dfcc clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e6dfcc)
#13 0x0000000007e3e09f clang::interp::Compiler<clang::interp::EvalEmitter>::visitAssignment(clang::Expr const*, clang::Expr const*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e3e09f)
#14 0x0000000007e718d2 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitBinaryOperator(clang::BinaryOperator const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e718d2)
#15 0x0000000007e6dfcc clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e6dfcc)
#16 0x0000000007e627e2 clang::interp::Compiler<clang::interp::EvalEmitter>::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e627e2)
#17 0x00000000079fb691 clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x79fb691)
#18 0x00000000079d3762 clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x79d3762)
#19 0x000000000794b7e3 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#20 0x000000000794d571 clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x794d571)
#21 0x0000000006935b16 clang::Sema::CheckForIntOverflow(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6935b16)
#22 0x000000000696c29c clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x696c29c)
#23 0x0000000006cf0777 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cf0777)
#24 0x000000000700328e clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x700328e)
#25 0x00000000067f96d4 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f96d4)
#26 0x00000000067f0db4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f0db4)
#27 0x00000000067f1bf9 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f1bf9)
#28 0x00000000067f9d4b clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f9d4b)
#29 0x00000000067fa55a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67fa55a)
#30 0x00000000066effdb clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66effdb)
#31 0x000000000672643d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672643d)
#32 0x00000000066e2dae clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e2dae)
#33 0x00000000066e354f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e354f)
#34 0x00000000066eb38a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66eb38a)
#35 0x00000000066ec325 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66ec325)
#36 0x00000000066ddeaa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66ddeaa)
#37 0x00000000049bc6e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49bc6e8)
#38 0x0000000004cb2f05 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4cb2f05)
#39 0x0000000004c2f1fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c2f1fe)
#40 0x0000000004da4e91 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4da4e91)
#41 0x0000000000db422f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb422f)
#42 0x0000000000daaeda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#43 0x0000000004a242a9 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
#44 0x0000000003f89f14 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f89f14)
#45 0x0000000004a248bf 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
#46 0x00000000049e699d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49e699d)
#47 0x00000000049e7a2e 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+++0x49e7a2e)
#48 0x00000000049ef265 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49ef265)
#49 0x0000000000db06e5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb06e5)
#50 0x0000000000c63c34 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc63c34)
#51 0x000079af81c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#52 0x000079af81c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#53 0x0000000000daa985 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdaa985)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkW29v46j2_jTuG-TIxv9f9IWbNvvralYzaqt9W2GME__qgC_gTHo__RXglOAmmeluPfdKO-pUqQ2H53nO4XBwMBKiXVNCrr3kxktur9AgN4xfv_iIc_ZdXFWsfr1-ID1n9YAJ96LSC8qNlL1QH-HKg6s1qyvWyQXjaw-u_u3BVcSKP2q22REvKL00MD_YC8qWStAw5sF878FivLD3ohvVMFO_AeBEDpzaq7fqd1DuWFuDCnEP5h4swKH1kQEA9sCLbscBlP1jCwcYxtoNwi-SI0wMIQuSUcE6hRt3iK49eKN-ohJ4cMUZkx5cdd1u6_ec_T_Bhz89uJKMdcKDq7HbqmsrD67KxycPrm5eJVmymnhwdU8l4f2jRPhlsfGiMgmVcc3N9IxKL1KqEN6bz0c9zIW6FRjx-qBDcvO9lRvwpKlfsLHmqPOiZQQ9uASSD8SL7rzkVg1fCkG4bBkFSgQY3kuyfXrtiViQbS9fRzFhBhrUdqReeEH57ctd-XgHxFBtWwkQqIY14KRnXALJwCQ-WrkZqgVmWyvXRM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