| Issue |
177133
|
| Summary |
[clang][bytecode] UNREACHABLE executed in llvm/tools/clang/lib/AST/ByteCode/Pointer.h
|
| Labels |
regression,
crash-on-valid,
clang:bytecode
|
| Assignees |
|
| Reporter |
k-arrows
|
Reproducer:
https://godbolt.org/z/c8jKbKfjx
```cpp
struct S {
constexpr int operator[](this const S& self, int i) {
return i + self.base;
}
int base = 20;
};
constexpr bool test() {
S s{};
return s[22] == 42;
}
static_assert(test());
```
Backtrace:
```console
Unknown clang::interp::Storage enum
UNREACHABLE executed at /root/llvm-project/llvm/tools/clang/lib/AST/ByteCode/Pointer.h:270!
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 -std=c++2b -fexperimental-new-constant-interpreter <source>
1. <source>:11:21: current parser token ';'
2. <source>:9:23: parsing function body 'test'
3. <source>:9:23: in compound statement ('{}')
#0 0x000000000431fc88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x431fc88)
#1 0x000000000431d0e4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x431d0e4)
#2 0x000000000425feb8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007e9d4bc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007e9d4bc969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007e9d4bc42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007e9d4bc287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000000000426a91a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426a91a)
#8 0x0000000007e32d1a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e32d1a)
#9 0x0000000008036adb clang::interp::Pointer::toAPValue(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8036adb)
#10 0x000000000802c312 void print<clang::interp::Pointer>(llvm::raw_ostream&, clang::interp::Pointer const&, clang::ASTContext&, clang::QualType) InterpFrame.cpp:0:0
#11 0x000000000802d892 clang::interp::InterpFrame::describe(llvm::raw_ostream&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x802d892)
#12 0x0000000008047074 clang::interp::State::addCallStack(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8047074)
#13 0x00000000080481ac clang::interp::State::diag(clang::SourceLocation, unsigned int, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x80481ac)
#14 0x0000000007fd4668 diagnoseNonConstVariable(clang::interp::InterpState&, clang::interp::CodePtr, clang::ValueDecl const*) Interp.cpp:0:0
#15 0x0000000007fd4c61 diagnoseUnknownDecl(clang::interp::InterpState&, clang::interp::CodePtr, clang::ValueDecl const*) Interp.cpp:0:0
#16 0x0000000007fdb5fb clang::interp::CheckDummy(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Block const*, clang::AccessKinds) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7fdb5fb)
#17 0x0000000007ffd0d1 clang::interp::CheckLoad(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Pointer const&, clang::AccessKinds) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ffd0d1)
#18 0x0000000007e4ddfd bool clang::interp::LoadPop<(clang::interp::PrimType)4, clang::interp::Integral<32u, true>>(clang::interp::InterpState&, clang::interp::CodePtr) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e4ddfd)
#19 0x000000000801a64e clang::interp::Interpret(clang::interp::InterpState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x801a64e)
#20 0x0000000008029b87 clang::interp::Call(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Function const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8029b87)
#21 0x00000000082c196d clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCallExpr(clang::CallExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x82c196d)
#22 0x00000000082c823a clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x82c823a)
#23 0x00000000082bc3d6 clang::interp::Compiler<clang::interp::EvalEmitter>::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x82bc3d6)
#24 0x0000000007e33c2d clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e33c2d)
#25 0x0000000007e23e63 clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e23e63)
#26 0x0000000007d913a3 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#27 0x0000000007d95d3f clang::Expr::isCXX11ConstantExpr(clang::ASTContext const&, clang::APValue*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7d95d3f)
#28 0x0000000007d96200 EvaluateCPlusPlus11IntegralConstantExpr(clang::ASTContext const&, clang::Expr const*, llvm::APSInt*) ExprConstant.cpp:0:0
#29 0x0000000007d9b9ef clang::Expr::getIntegerConstantExpr(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7d9b9ef)
#30 0x0000000006d06e57 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) (.constprop.0) SemaChecking.cpp:0:0
#31 0x0000000006d07a95 clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d07a95)
#32 0x00000000070aca67 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70aca67)
#33 0x00000000073e7bde clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x73e7bde)
#34 0x00000000073e8967 clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x73e8967)
#35 0x0000000006b7e8fa clang::Parser::ParseReturnStatement() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b7e8fa)
#36 0x0000000006b82d3d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b82d3d)
#37 0x0000000006b83c56 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b83c56)
#38 0x0000000006b8c59e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b8c59e)
#39 0x0000000006b8cdea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b8cdea)
#40 0x0000000006a92fab clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a92fab)
#41 0x0000000006ac941d 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+++0x6ac941d)
#42 0x0000000006a865ab clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a865ab)
#43 0x0000000006a86d9f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a86d9f)
#44 0x0000000006a8e843 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a8e843)
#45 0x0000000006a8f785 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a8f785)
#46 0x0000000006a709da clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a709da)
#47 0x0000000004c885e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c885e8)
#48 0x0000000004f83045 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f83045)
#49 0x0000000004f02a1e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f02a1e)
#50 0x000000000507e23d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x507e23d)
#51 0x0000000000ddcbae cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xddcbae)
#52 0x0000000000dd357a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#53 0x0000000000dd36fd int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#54 0x0000000004cfc019 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
#55 0x0000000004260354 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4260354)
#56 0x0000000004cfc62f 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
#57 0x0000000004cbd002 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4cbd002)
#58 0x0000000004cbdfae 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+++0x4cbdfae)
#59 0x0000000004cc53f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4cc53f5)
#60 0x0000000000dd8f21 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdd8f21)
#61 0x0000000000c957d4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc957d4)
#62 0x00007e9d4bc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#63 0x00007e9d4bc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#64 0x0000000000dd3015 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdd3015)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs