<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 - clang failure using CTRE in templated class/function"
href="https://bugs.llvm.org/show_bug.cgi?id=48134">48134</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang failure using CTRE in templated class/function
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>faceprint@faceprint.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Below code produces a segfault in my build of 8.0.1 with my production code,
and the below error on trunk in compiler explorer with the below sample code.
The exact same code without the template compiles fine.
#include <ctre.hpp>
template <typename T>
bool match(std::string_view line) {
static constexpr auto pattern = ctll::fixed_string("aloha|[a-z]*");
return ctre::match<pattern>(line);
}
bool call_match(std::string_view line) {
return match<int>(line);
}
<a href="https://compiler-explorer.com/z/c8vzTx">https://compiler-explorer.com/z/c8vzTx</a>
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/celibs/boost_1_70_0
-isystem/opt/compiler-explorer/libs/ctre/main/include
-isystem/opt/compiler-explorer/libs/ctre/dfa/include -Os -std=c++17 <source>
1. <source>:6:32: current parser token '('
2. <source>:4:35: parsing function body 'match'
3. <source>:4:35: in compound statement ('{}')
#0 0x0000561ae63bef8c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2ddaf8c)
#1 0x0000561ae63bcd24 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2dd8d24)
#2 0x0000561ae63bcfb5 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2dd8fb5)
#3 0x0000561ae632bb78 CrashRecoverySignalHandler(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d47b78)
#4 0x00007fc4129b53c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#5 0x0000561ae87f93d6
clang::LocalInstantiationScope::InstantiatedLocal(clang::Decl const*,
clang::Decl*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52153d6)
#6 0x0000561ae8836302 clang::Sema::FindInstantiatedDecl(clang::SourceLocation,
clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5252302)
#7 0x0000561ae880c6ac (anonymous
namespace)::TemplateInstantiator::transformNonTypeTemplateParmRef(clang::NonTypeTemplateParmDecl*,
clang::SourceLocation, clang::TemplateArgument)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52286ac)
#8 0x0000561ae87fe611 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x521a611)
#9 0x0000561ae880d7a8 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc
const&, clang::TemplateArgumentLoc&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52297a8)
#10 0x0000561ae880fc18 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&,
clang::TemplateSpecializationTypeLoc, clang::TemplateName)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x522bc18)
#11 0x0000561ae880cd9b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTSIInObjectScope(clang::TypeLoc,
clang::QualType, clang::NamedDecl*, clang::CXXScopeSpec&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5228d9b)
#12 0x0000561ae880d20e clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformNestedNameSpecifierLoc(clang::NestedNameSpecifierLoc,
clang::QualType, clang::NamedDecl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x522920e)
#13 0x0000561ae8810fcf clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformDependentNameType(clang::TypeLocBuilder&,
clang::DependentNameTypeLoc, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x522cfcf)
#14 0x0000561ae8807d19 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5223d19)
#15 0x0000561ae880b4ba clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52274ba)
#16 0x0000561ae880d74b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc
const&, clang::TemplateArgumentLoc&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x522974b)
#17 0x0000561ae880fc18 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&,
clang::TemplateSpecializationTypeLoc, clang::TemplateName)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x522bc18)
#18 0x0000561ae88089a9 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52249a9)
#19 0x0000561ae880b4ba clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52274ba)
#20 0x0000561ae8811112 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTypeWithDeducedTST(clang::TypeSourceInfo*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x522d112)
#21 0x0000561ae88144dc clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXUnresolvedConstructExpr(clang::CXXUnresolvedConstructExpr*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52304dc)
#22 0x0000561ae87feb9a clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x521ab9a)
#23 0x0000561ae87ff63b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x521b63b)
#24 0x0000561ae8800ac4 clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x521cac4)
#25 0x0000561ae882e770
clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*,
clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x524a770)
#26 0x0000561ae8838e7a clang::Sema::BuildVariableInstantiation(clang::VarDecl*,
clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&,
llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*,
clang::DeclContext*, clang::LocalInstantiationScope*, bool,
clang::VarTemplateSpecializationDecl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5254e7a)
#27 0x0000561ae8839796
clang::TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(clang::VarTemplateDecl*,
clang::VarDecl*, clang::TemplateArgumentListInfo const&,
llvm::ArrayRef<clang::TemplateArgument>, clang::VarTemplateSpecializationDecl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5255796)
#28 0x0000561ae8839b44
clang::Sema::BuildVarTemplateInstantiation(clang::VarTemplateDecl*,
clang::VarDecl*, clang::TemplateArgumentList const&,
clang::TemplateArgumentListInfo const&,
llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::SourceLocation,
llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*,
clang::LocalInstantiationScope*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5255b44)
#29 0x0000561ae872a1dc clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*,
clang::SourceLocation, clang::SourceLocation, clang::TemplateArgumentListInfo
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x51461dc)
#30 0x0000561ae872a2f5 clang::Sema::CheckVarTemplateId(clang::CXXScopeSpec
const&, clang::DeclarationNameInfo const&, clang::VarTemplateDecl*,
clang::SourceLocation, clang::TemplateArgumentListInfo const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x51462f5)
#31 0x0000561ae872b805 clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec
const&, clang::SourceLocation, clang::LookupResult&, bool,
clang::TemplateArgumentListInfo const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5147805)
#32 0x0000561ae844f026 clang::Sema::ActOnIdExpression(clang::Scope*,
clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool,
clang::CorrectionCandidateCallback*, bool, clang::Token*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4e6b026)
#33 0x0000561ae80fc197
clang::Parser::tryParseCXXIdExpression(clang::CXXScopeSpec&, bool,
clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b18197)
#34 0x0000561ae80fc3c2 clang::Parser::ParseCXXIdExpression(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b183c2)
#35 0x0000561ae80e1f6f
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4afdf6f)
#36 0x0000561ae80e30b3
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4aff0b3)
#37 0x0000561ae80e4756
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b00756)
#38 0x0000561ae80e5ef4
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b01ef4)
#39 0x0000561ae80e6b89
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b02b89)
#40 0x0000561ae813963f clang::Parser::ParseReturnStatement()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b5563f)
#41 0x0000561ae813c58f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b5858f)
#42 0x0000561ae813d5a9
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b595a9)
#43 0x0000561ae8143be9 clang::Parser::ParseCompoundStatementBody(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b5fbe9)
#44 0x0000561ae81473c3 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b633c3)
#45 0x0000561ae809be87
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ab7e87)
#46 0x0000561ae8160159
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b7c159)
#47 0x0000561ae816260c
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b7e60c)
#48 0x0000561ae8162bd4
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4b7ebd4)
#49 0x0000561ae80c5415
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ae1415)
#50 0x0000561ae809d5ab
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ab95ab)
#51 0x0000561ae809eb11
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4abab11)
#52 0x0000561ae8091c79 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4aadc79)
#53 0x0000561ae6bd8549 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x35f4549)
#54 0x0000561ae6b9129b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x35ad29b)
#55 0x0000561ae6c9fecb
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36bbecb)
#56 0x0000561ae44e3ddc cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xeffddc)
#57 0x0000561ae44e04bd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xefc4bd)
#58 0x0000561ae6a5de35 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)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3479e35)
#59 0x0000561ae632bc53
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d47c53)
#60 0x0000561ae6a5e967
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.164)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x347a967)
#61 0x0000561ae6a380aa
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34540aa)
#62 0x0000561ae6a38bff
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+++0x3454bff)
#63 0x0000561ae6a41a25
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x345da25)
#64 0x0000561ae44144d6 main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe304d6)
#65 0x00007fc4124660b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#66 0x0000561ae44e003a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xefc03a)
clang-12: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
Compiler returned: 139</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>