<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 --- - mismatched argument pack lengths -> segfault or no error"
   href="http://llvm.org/bugs/show_bug.cgi?id=16303">16303</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>mismatched argument pack lengths -> segfault or no error
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.2
          </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>temporal@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>Created <span class=""><a href="attachment.cgi?id=10664" name="attach_10664" title="code that sefaults clang">attachment 10664</a> <a href="attachment.cgi?id=10664&action=edit" title="code that sefaults clang">[details]</a></span>
code that sefaults clang

I was learning how non-recursive tuples are implemented, and ran into a
problem:  Clang didn't complain if I passed too many arguments to my tuple
constructor, and segfaulted if I passed too few.  It appears that in a place
where I am unpacking multiple variadic template argument packs, Clang is not
checking that the two packs have the same length.  GCC reports the appropriate
error in both cases.

Sample code attached.  Compile with:
  clang++ -std=c++11 -c test.c++

Error dump:

0  libLLVM-3.2.so.1 0x00007fcde4fb567f
1  libLLVM-3.2.so.1 0x00007fcde4fb5ae9
2  libpthread.so.0  0x00007fcde4068bd0
3  clang            0x0000000000e7fb68
clang::ASTContext::getSubstTemplateTypeParmType(clang::TemplateTypeParmType
const*, clang::QualType) const + 296
4  clang            0x0000000000b1e5d9
5  clang            0x0000000000b2cf60
6  clang            0x0000000000b2e618
7  clang            0x0000000000b27325
8  clang            0x0000000000b28b68
9  clang            0x0000000000b348c4
10 clang            0x0000000000b264fa
11 clang            0x0000000000b3b72b
12 clang            0x0000000000b26020
13 clang            0x0000000000b36a63
14 clang            0x0000000000b26493
15 clang            0x0000000000b3ea5f clang::Sema::SubstExpr(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&) + 79
16 clang            0x0000000000b41a0d
clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool) + 77
17 clang            0x0000000000b47441
clang::Sema::InstantiateMemInitializers(clang::CXXConstructorDecl*,
clang::CXXConstructorDecl const*, clang::MultiLevelTemplateArgumentList const&)
+ 1009
18 clang            0x0000000000b4dd8d
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2189
19 clang            0x0000000000b4cd2e
clang::Sema::PerformPendingInstantiations(bool) + 494
20 clang            0x0000000000b4dcea
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2026
21 clang            0x0000000000b4cd2e
clang::Sema::PerformPendingInstantiations(bool) + 494
22 clang            0x00000000008e1903 clang::Sema::ActOnEndOfTranslationUnit()
+ 2323
23 clang            0x0000000000861613
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 387
24 clang            0x0000000000859afb clang::ParseAST(clang::Sema&, bool,
bool) + 267
25 clang            0x00000000005f50b1 clang::FrontendAction::Execute() + 97
26 clang            0x00000000005dc57a
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 282
27 clang            0x00000000005c5e92
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1378
28 clang            0x00000000005c0e88 cc1_main(char const**, char const**,
char const*, void*) + 1160
29 clang            0x00000000005bfd84 main + 7316
30 libc.so.6        0x00007fcde3799ea5 __libc_start_main + 245
31 clang            0x00000000005c0889
Stack dump:
0.    Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
test.c++ -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 2.23.2 -momit-leaf-frame-pointer -coverage-file
/home/kenton/test/test.o -resource-dir /usr/bin/../lib/clang/3.2
-fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/x86_64-linux-gnu
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/x86_64-linux-gnu
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/backward
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/x86_64-linux-gnu
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/backward
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/x86_64-linux-gnu
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.2/include -internal-isystem
/usr/include/clang/3.2/include/ -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include -std=c++11
-fdeprecated-macro -fdebug-compilation-dir /home/kenton/test -ferror-limit 19
-fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -o test.o -x c++ test.c++ 
1.    <eof> parser at end of file
2.    test.c++:37:3: instantiating function definition 'Tuple'
3.    test.c++:28:10: instantiating function definition 'TupleImpl'
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM
3.2)
Target: x86_64-pc-linux-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>