Skip to content

[clang] -fexperimental-new-constant-interpreter option causes a crash #152822

@k-arrows

Description

@k-arrows

Reproducer:
https://godbolt.org/z/fTvxjYe47

namespace B {
  struct A { ~A(); };
  int &h() __attribute__((enable_if((A(), true), "")));
}

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-trunk/bin/clang++ -gdwarf-4 -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 -fexperimental-new-constant-interpreter <source>
1.	<source>:3:55: current parser token ';'
2.	<source>:1:1: parsing namespace 'B'
 #0 0x0000000003cc2ed8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cc2ed8)
 #1 0x0000000003cc08ac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cc08ac)
 #2 0x0000000003c10bd8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007b43fc042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000000000790ebe0 clang::interp::Compiler<clang::interp::EvalEmitter>::allocateLocal(llvm::PointerUnion<clang::Decl const*, clang::Expr const*>&&, clang::QualType, clang::ValueDecl const*, clang::interp::ScopeKind, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x790ebe0)
 #5 0x000000000791b3b7 clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x791b3b7)
 #6 0x000000000791fdef clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCXXBindTemporaryExpr(clang::CXXBindTemporaryExpr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x791fdef)
 #7 0x0000000007914d39 clang::interp::Compiler<clang::interp::EvalEmitter>::discard(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x7914d39)
 #8 0x000000000791d62b clang::interp::Compiler<clang::interp::EvalEmitter>::VisitBinaryOperator(clang::BinaryOperator const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x791d62b)
 #9 0x000000000791b368 clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x791b368)
#10 0x000000000760865f clang::interp::EvalEmitter::interpretCall(clang::FunctionDecl const*, clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x760865f)
#11 0x00000000075152e4 clang::interp::Context::isPotentialConstantExprUnevaluated(clang::interp::State&, clang::Expr const*, clang::FunctionDecl const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x75152e4)
#12 0x00000000074a44d8 clang::Expr::isPotentialConstantExprUnevaluated(clang::Expr*, clang::FunctionDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x74a44d8)
#13 0x00000000066882f5 checkFunctionConditionAttr(clang::Sema&, clang::Decl*, clang::ParsedAttr const&, clang::Expr*&, llvm::StringRef&) (.part.0) SemaDeclAttr.cpp:0:0
#14 0x00000000066b2c4e handleEnableIfAttr(clang::Sema&, clang::Decl*, clang::ParsedAttr const&) SemaDeclAttr.cpp:0:0
#15 0x00000000066c0161 ProcessDeclAttribute(clang::Sema&, clang::Scope*, clang::Decl*, clang::ParsedAttr const&, clang::Sema::ProcessDeclAttributeOptions const&) (.isra.0) SemaDeclAttr.cpp:0:0
#16 0x00000000066c285b clang::Sema::ProcessDeclAttributes(clang::Scope*, clang::Decl*, clang::Declarator const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x66c285b)
#17 0x0000000006678ad4 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6678ad4)
#18 0x000000000667e294 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x667e294)
#19 0x000000000667ebcc clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x667ebcc)
#20 0x00000000062c36a6 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62c36a6)
#21 0x00000000062d985c clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62d985c)
#22 0x00000000062865ef clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62865ef)
#23 0x00000000062873d7 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62873d7)
#24 0x000000000628ffcf clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x628ffcf)
#25 0x00000000062f7bdd clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62f7bdd)
#26 0x00000000062f883d clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62f883d)
#27 0x00000000062dcc51 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62dcc51)
#28 0x0000000006290001 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6290001)
#29 0x00000000062917e0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62917e0)
#30 0x0000000006291d30 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6291d30)
#31 0x000000000627ff13 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x627ff13)
#32 0x00000000046095cd clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46095cd)
#33 0x000000000491503a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x491503a)
#34 0x000000000488e47b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x488e47b)
#35 0x0000000004a09483 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4a09483)
#36 0x0000000000dbf425 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdbf425)
#37 0x0000000000db739d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#38 0x000000000467b979 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
#39 0x0000000003c10ff3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c10ff3)
#40 0x000000000467bb99 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
#41 0x000000000463ee8d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x463ee8d)
#42 0x000000000463fe41 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x463fe41)
#43 0x0000000004649c9c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4649c9c)
#44 0x0000000000dbbc01 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdbbc01)
#45 0x0000000000c6b494 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc6b494)
#46 0x00007b43fc029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#47 0x00007b43fc029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#48 0x0000000000db6e35 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdb6e35)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:bytecodeIssues for the clang bytecode constexpr interpreterclang:frontendLanguage frontend issues, e.g. anything involving "Sema"crashPrefer [crash-on-valid] or [crash-on-invalid]generated by fuzzer

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions