<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Crash with template lambda and std::index_sequence"
href="https://bugs.llvm.org/show_bug.cgi?id=49388">49388</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash with template lambda and std::index_sequence
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vittorio.romeo@outlook.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Closely related to #49387. The following code:
#include <utility>
struct S
{
template <int> using N = int;
static constexpr int size = 5;
};
template <typename>
static void f()
{
const auto l = [&]<typename>() {};
[&]<std::size_t... Is>(std::index_sequence<Is...>)
{
((l
.template operator()<typename S::template N<Is>>()),
...);
}
(std::make_index_sequence<S::size> {});
}
int main()
{
f<int>();
}
Results in a compiler crash:
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
./output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics
-fno-crash-diagnostics -isystem/opt/compiler-explorer/libs/boost_1_64_0
-std=c++2a -stdlib=libc++ -Wall -Wextra -Wpedantic <source>
1. <eof> parser at end of file
2. <source>:10:13: instantiating function definition 'f<int>'
3. <source>:14:5: instantiating function definition 'f()::(anonymous
class)::operator()<0, 1, 2, 3, 4>'
#0 0x0000559a3b737bbc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3056bbc)
#1 0x0000559a3b735964 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3054964)
#2 0x0000559a3b735be5 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3054be5)
#3 0x0000559a3b69c408 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
#4 0x00007fcff457c3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#5 0x0000559a3e078ca4 clang::TemplateArgument::isPackExpansion() const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5997ca4)
#6 0x0000559a3db62c0d
clang::Sema::collectUnexpandedParameterPacks(clang::TemplateArgument,
llvm::SmallVectorImpl<std::pair<llvm::PointerUnion<clang::TemplateTypeParmType
const*, clang::NamedDecl*>, clang::SourceLocation> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5481c0d)
#7 0x0000559a3db06d30 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXFoldExpr(clang::CXXFoldExpr*)
SemaTemplateInstantiate.cpp:0:0
#8 0x0000559a3db009d8 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
SemaTemplateInstantiate.cpp:0:0
#9 0x0000559a3db27320 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*,
clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::StmtDiscardKind)
SemaTemplateInstantiate.cpp:0:0
#10 0x0000559a3db2c24d clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
SemaTemplateInstantiate.cpp:0:0
#11 0x0000559a3db2c14a clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x544b14a)
#12 0x0000559a3db3f1d4
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x545e1d4)
#13 0x0000559a3d486d4f
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation,
llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4da5d4f)
#14 0x0000559a3da9ffcd clang::Sema::DeduceReturnType(clang::FunctionDecl*,
clang::SourceLocation, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53befcd)
#15 0x0000559a3d71c3ef clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*,
llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool,
bool, clang::ObjCInterfaceDecl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x503b3ef)
#16 0x0000559a3d97bc8f CreateFunctionRefExpr(clang::Sema&,
clang::FunctionDecl*, clang::NamedDecl*, clang::Expr const*, bool,
clang::SourceLocation, clang::DeclarationNameLoc const&) SemaOverload.cpp:0:0
#17 0x0000559a3d9b37bf clang::Sema::BuildCallToObjectOfClassType(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d27bf)
#18 0x0000559a3d7527a2 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x50717a2)
#19 0x0000559a3d753374 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5072374)
#20 0x0000559a3db07b5d clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*)
SemaTemplateInstantiate.cpp:0:0
#21 0x0000559a3db00abd clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
SemaTemplateInstantiate.cpp:0:0
#22 0x0000559a3db27320 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*,
clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::StmtDiscardKind)
SemaTemplateInstantiate.cpp:0:0
#23 0x0000559a3db2c24d clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
SemaTemplateInstantiate.cpp:0:0
#24 0x0000559a3db2c14a clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x544b14a)
#25 0x0000559a3db3f1d4
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x545e1d4)
#26 0x0000559a3db3e342 clang::Sema::PerformPendingInstantiations(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x545d342)
#27 0x0000559a3d49e8d9
clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind)
(.part.1373) Sema.cpp:0:0
#28 0x0000559a3d49efe5 clang::Sema::ActOnEndOfTranslationUnit()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4dbdfe5)
#29 0x0000559a3d38e80a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4cad80a)
#30 0x0000559a3d3817f9 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ca07f9)
#31 0x0000559a3c5b0792 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ecf792)
#32 0x0000559a3bfabe81 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38cae81)
#33 0x0000559a3bf4b9a3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x386a9a3)
#34 0x0000559a3c072ec3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3991ec3)
#35 0x0000559a396b60ec cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xfd50ec)
#36 0x0000559a396b226d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#37 0x0000559a3be06645 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#38 0x0000559a3b69c4e3
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fbb4e3)
#39 0x0000559a3be06f78
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const (.part.166) Job.cpp:0:0
#40 0x0000559a3bddf34a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36fe34a)
#41 0x0000559a3bddfe9f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36fee9f)
#42 0x0000559a3bde8da5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3707da5)
#43 0x0000559a395cfd5e main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xeeed5e)
#44 0x00007fcff402d0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#45 0x0000559a396b1dea _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xfd0dea)
clang-13: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
Compiler returned: 139
Live on Compiler Explorer: <a href="https://gcc.godbolt.org/z/bWWe9d">https://gcc.godbolt.org/z/bWWe9d</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>