<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/152822>152822</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] -fexperimental-new-constant-interpreter option causes a crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
crash
</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/fTvxjYe47
```cpp
namespace B {
struct A { ~A(); };
int &h() __attribute__((enable_if((A(), true), "")));
}
```
Backtrace:
```console
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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkW1tT5LgV_jXmRWXKLd8feDANbNjMZsjAbm2eumT5uNHilhxZZpo85LenJNu45b4MzJqtmsoU1DS6ft-nI52jS5OmYWsOcOGEl054dUZa9SjkxZNLpBRfm7NcFC8XX6CWomgpSMfPHC97VKpu9Ed84-CbtShyUalzIdcOvvmPg2_Kh-ftH_-CIHa8zIm87ofWteNlnGygqQkFdImc-NLxMoQaJVuqUKYT0H8zBycOTh1fF7hy_K4M4wo5OHrsMtFqRZSSLG8VrFYmLQFO8gpWrOz-HJrBS6RkC_1HB2Pzk_Y_pnXdzQ5Q_dnLLgl9UpJQ6CiPNARvRAWOl919us7ur1HT5humEEF5u0YSaiEVUgJNNGLqsc3Pqdg4-Kaqnof_3FqKP4AqB9-wpmmhcfANIrxAjNOqLQCpR0BUkuYR5a-A8BLVUg8JhaaBAjWilV2yrkmaRlBGFBRIthw1VLJanTtedq8IfUJFu6k7St6546V3Uqwl2SAi1-0GuNKQkYNvRK0xUbGpWQXShW1dCQlSp1WEr10lW_7k4Juc8SHNwZcOvkTuuvhKZOkGyF0jV-jGSF3rJltVt-q8Qe5GU0euu00ilzQbt3nhimwd_4pxBRVySy7cZ5C5aEDnI_ceue6aUlcJUdFHwrjjX50EqQs3nNTNo1DILamohHQLRtZcNIrRpuvDCDtJhm0NkmkpSOVy-OrqAVeEK1eDk7UEBRI5_rJX3b92vGyhpbTS_Mx3_CwMtZy0lRK4QjWRDUikxBNw5OBYWx_WcwQfqL7of00txtdonDkOjvuKyMG-h7ytN_zzKcVQ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