<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Unexpected template recursion limit hit for partially-specialized member template"
   href="http://llvm.org/bugs/show_bug.cgi?id=18495">18495</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unexpected template recursion limit hit for partially-specialized member template
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>lhyatt@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>===========================
template<typename S, typename... T> struct X {
    template<bool stop = (sizeof...(T) >= 10), typename = void>
    struct Next {
        typedef typename X<S, T..., void>::type type;
    };
    typedef typename Next<>::type type;
};

template<typename S, typename... T>
template<typename U>
struct X<S, T...>::Next<true, U> {
    typedef S type;
};

static_assert(sizeof(X<double>::type) == sizeof(double), "");
===========================

I believe this should be a valid program, the template recursion should stop
after 10 instantiations when the partial specialization comes into play and be
OK. clang 3.3 recurses indefinitely until it hits whatever limit you give it.
g++ 4.7 works as expected. clang also works fine if I switch to make the
non-recursing Next<true> the primary template, and the recursing Next<false>
the partial specialization defined outside the class:

(works fine):
===========================
template<typename S, typename... T> struct X {
    template<bool stop = (sizeof...(T) >= 10), typename = void>
    struct Next {
        typedef S type;
    };
    typedef typename Next<>::type type;
};

template<typename S, typename... T>
template<typename U>
struct X<S, T...>::Next<false, U> {
    typedef typename X<S, T..., void>::type type;
};

static_assert(sizeof(X<double>::type) == sizeof(double), "");
===========================

So I guess it's a question of whether clang is incorrect in instantiating the
primary template that causes the indefinite recursion rather than the partial
specialization that applies, or g++ is incorrect in failing to do so...</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>