[llvm-bugs] [Bug 34742] New: Infinite loop during auto return type deduction

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 26 17:37:29 PDT 2017


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

            Bug ID: 34742
           Summary: Infinite loop during auto return type deduction
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rtrieu at google.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The auto return type of a member function depends on its own return value. 
When instantiating the function, template deduction recursively tries to deduce
the return type with no end.

$ cat foo.cc
struct S {
  template<class X = S>
  static auto foo() -> decltype(X::foo());
};

void run() {
  S::foo<>();
};

$ clang foo.cc -std=c++11
#0 0x0000000001e191e4 PrintStackTraceSignalHandler(void*)
(/usr/local/bin/clang-
3.5+0x1e191e4)
#1 0x0000000001e19546 SignalHandler(int) (/usr/local/bin/clang-3.5+0x1e19546)
#2 0x00007fcfb4081330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x1033
0)
#3 0x00000000033736d6 clang::Sema::BuildOverloadedCallExpr(clang::Scope*,
clang:
:Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayR
ef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool)
(/usr/local/b
in/clang-3.5+0x33736d6)
#4 0x000000000315196c clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool) (/usr/local/bin/clang-3.5+0x315196c)
#5 0x000000000349c0ff clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*)
(/usr/local/bin/clang-3.5+0x349c0ff)
#6 0x0000000003488c9e clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc) (/usr/local/bin/clang-3.5+0x3488c9e)
#7 0x000000000348cb99
clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName, clang::CXXRecordDecl*, unsigned int)
(/usr/local/bin/clang-3.5+0x348cb99)
#8 0x00000000034c5bc4
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&)
(/usr/local/bin/clang-3.5+0x34c5bc4)
#9 0x00000000034c312c
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*, bool) (/usr/local/bin/clang-3.5+0x34c312c)
#10 0x00000000034cab16 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)
(/usr/local/bin/clang-3.5+0x34cab16)
#11 0x000000000344b4c6
clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*,
llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&,
llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool,
llvm::function_ref<bool ()>) (/usr/local/bin/clang-3.5+0x344b4c6)
#12 0x000000000344cec0
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool,
llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)
(/usr/local/bin/clang-3.5+0x344cec0)
#13 0x000000000335fc24
clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::TemplateArgumentListInfo*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool)
(/usr/local/bin/clang-3.5+0x335fc24)
#14 0x00000000033731bd AddOverloadedCallCandidate(clang::Sema&,
clang::DeclAccessPair, clang::TemplateArgumentListInfo*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool)
(/usr/local/bin/clang-3.5+0x33731bd)
#15 0x0000000003372fc8
clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool)
(/usr/local/bin/clang-3.5+0x3372fc8)
#16 0x00000000033733db clang::Sema::buildOverloadedCallSet(clang::Scope*,
clang::Expr*, clang::UnresolvedLookupExpr*,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation,
clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*)
(/usr/local/bin/clang-3.5+0x33733db)
#17 0x00000000033737ec clang::Sema::BuildOverloadedCallExpr(clang::Scope*,
clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool,
bool) (/usr/local/bin/clang-3.5+0x33737ec)

< Repeat from #4 Sema::ActOnCallExpr >

-- 
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/20170927/0a2318ea/attachment.html>


More information about the llvm-bugs mailing list