<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 - Infinite loop during auto return type deduction"
   href="https://bugs.llvm.org/show_bug.cgi?id=34742">34742</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Infinite loop during auto return type deduction
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rtrieu@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 ></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>