[llvm-bugs] [Bug 48134] New: clang failure using CTRE in templated class/function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 10 05:14:28 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48134

            Bug ID: 48134
           Summary: clang failure using CTRE in templated class/function
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: faceprint at faceprint.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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);
}


https://compiler-explorer.com/z/c8vzTx



PLEASE submit a bug report to https://bugs.llvm.org/ 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>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
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>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201110/0d0589f6/attachment-0001.html>


More information about the llvm-bugs mailing list