<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 --- - Compiler crash in incorrect, heavily-templated code" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23945&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=KfCw9qOcAtgbLbW9G3QFyLxNXr1M4cvE-sMwd4TKw3c&s=L39yR6VpYmcSEJABo94pcf9gMsjdCz8rxyXipawZb6U&e=">23945</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler crash in incorrect, heavily-templated code
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>michael@ensslin.cc
          </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>Created <span class=""><a href="attachment.cgi?id=14518" name="attach_14518" title="tar.xz archive of test.cpp and the crash reproducers.">attachment 14518</a> <a href="attachment.cgi?id=14518&action=edit" title="tar.xz archive of test.cpp and the crash reproducers.">[details]</a></span>
tar.xz archive of test.cpp and the crash reproducers.

Take this failed attempt at a template specialization:

#include <tuple>

template<typename T, typename ... Ts>
struct S {
    template<typename ... Us>
    void foo(std::tuple<T, Us ..., Ts ...>, Us ...) {
    }
};

template<typename T, typename ... Ts>
void S<T, Ts ...>::foo<>(std::tuple<T, Ts ...>) {}


clang++{3.5, 3.6, 3.7} -std=c++{11, 14} will crash and print a stacktrace,
albeit slightly different ones (as is to be expected, I guess).

I'm using the compiler versions from the Debian Sid repository.

$ clang++-3.7 -std=c++14 -c test.cpp
test.cpp:13:20: error: cannot specialize a member of an unspecialized template
void S<T, Ts ...>::foo<>(std::tuple<T, Ts ...>) {}
                   ^  ~~
0  libLLVM-3.7.so.1 0x00007f53beeb49b5
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  libLLVM-3.7.so.1 0x00007f53beeb3fc9
2  libpthread.so.0  0x00007f53bda158d0
3  clang            0x00000000012b3168
clang::ASTContext::getSubstTemplateTypeParmType(clang::TemplateTypeParmType
const*, clang::QualType) const + 200
4  clang            0x0000000000e7d30f
5  clang            0x0000000000e8a8f9
6  clang            0x0000000000e8b955
7  clang            0x0000000000e954e5
8  clang            0x0000000000e9927f
9  clang            0x0000000000e8a769
10 clang            0x0000000000e8a95f
11 clang            0x0000000000e8b955
12 clang            0x0000000000e8ba43
clang::Sema::SubstType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName) + 83
13 clang            0x0000000000e9e9d8
clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*,
clang::MultiLevelTemplateArgumentList const&, int, llvm::Optional<unsigned
int>, bool) + 88
14 clang            0x0000000000e9f1ba
15 clang            0x0000000000e9f577
16 clang            0x0000000000ea0cc0
clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName, clang::CXXRecordDecl*, unsigned int) + 1872
17 clang            0x0000000000ea81e2
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&) + 114
Stack dump:
0.    Program arguments: /usr/lib/llvm-3.7/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-main-file-name test.cpp -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.25
-dwarf-column-info -coverage-file /tmp/llvmbug/test.cpp -resource-dir
/usr/lib/llvm-3.7/bin/../lib/clang/3.7.0 -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/llvm-3.7/bin/../lib/clang/3.7.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++14 -fdeprecated-macro
-fdebug-compilation-dir /tmp/llvmbug -ferror-limit 19 -fmessage-length 190
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o test.o -x c++ test.cpp 
1.    test.cpp:13:49: current parser token '{'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Debian clang version 3.7.0-svn239806-1+b1 (trunk) (based on LLVM 3.7.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

The crash reproducers, as suggested by the error message, are attached (but
they're rather bloated, due to my #include <tuple>, which I didn't manage to
remove, so I suggest not using them.</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>