<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 constexpr function template"
   href="http://llvm.org/bugs/show_bug.cgi?id=19517">19517</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unexpected template recursion limit hit for constexpr function template
          </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>Windows NT
          </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>kariya_mitsuru@hotmail.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>The sample code below causes a fatal error.

========================================
template<typename T>
constexpr T f(T const&);

template<typename T>
constexpr T g(T const& val) {
    return val >= 10 ? val : f(val + 1);
}

template<typename T>
constexpr T f(T const& val) {
    return g(val);
}

int main() {
    return f(0);
}
========================================

I think that this code should be compiled successfully.

Note that this code is compiled successfully if these functions are not
constexpr function.
(e.g. removing "constexpr" specifier from the function g)

I suspect that this is caused by <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - constexpr function template specializations are not instantiated if they are used before they are defined"
   href="show_bug.cgi?id=16008">bug 16008</a>.

c.f.
<a href="http://melpon.org/wandbox/permlink/LVfTzRBLPLsKweNG">http://melpon.org/wandbox/permlink/LVfTzRBLPLsKweNG</a></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>