<html>
    <head>
      <base href="https://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 --- - clang crashes due to infinite template recursion" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23943&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=szTO8fCrZU-uRAEu_ee8H3q2XwtYTPamvbWtOoTthxs&s=d24SiUNYc7mNcjQQRcvhZ7Uk4tkwihH6qr80wuu7FDE&e=">23943</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes due to infinite template recursion
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </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>Frontend
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14517" name="attach_14517" title="the crash backtrace">attachment 14517</a> <a href="attachment.cgi?id=14517&action=edit" title="the crash backtrace">[details]</a></span>
the crash backtrace

Clang crashes when given a type dependent on infinite-recursive template as a
template parameter.

The code is not valid as it is, but the clang crashing was not the expected
reaction.

You can reproduce the issue by compiling the following code with Clang 3.6.1
(I'm using the build from MSYS2)

template<typename T>
struct Concat
{
    typedef int type;
};

template<typename T, T Count>
struct Iota
{
    typedef typename Concat<
        typename Iota<T, Count-1>::type
    >::type type;
};

Iota<int, 4>::type err;

int main() {}


The run script is as follows:

 "C:\\__MOJE\\prog\\MSYS2_Toolset64\\mingw64\\bin\\clang++.exe" "-cc1"
"-triple" "x86_64-w64-windows-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "ice.cpp" "-mrelocation-model" "pic"
"-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno"
"-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu"
"x86-64" "-target-linker-version" "2.25" "-dwarf-column-info" "-std=c++11"
"-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "0"
"-mstackrealign" "-fno-use-cxa-atexit" "-fobjc-runtime=gcc" "-fcxx-exceptions"
"-fexceptions" "-fdiagnostics-show-option" "-x" "c++" "ice-143b03.cpp"

The trace is in the attachment.

The clang++ -v output is:

clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-w64-windows-gnu
Thread model: posix</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>