<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 --- - Missing expansion of function parameter pack from early substitution of explicit template arguments"
   href="https://llvm.org/bugs/show_bug.cgi?id=22945">22945</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing expansion of function parameter pack from early substitution of explicit template arguments
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>hstong@ca.ibm.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>N3290 subclause 14.8.2 [temp.deduct] paragraphs 2 to 5 specifies that explicit
template arguments are substituted into the type of the function template prior
to template argument deduction.
In the case below, Clang rejects the call to "foo" (but adding -DUSE_DEFAULT
makes it work, which seems to indicate that it understands that the "A<N> *..."
expands to "A<0> *").
If substitution is performed on the type of "foo" such that "A<N> *..." expands
to "A<0> *", then the case of foo/bar should behave like zip/zap, but that it
not the case with Clang.

### SOURCE (<stdin>):
#if USE_DEFAULT
# define DEFAULT_ARG = int
#else
# define DEFAULT_ARG
#endif

template <int> struct A { };

template <typename T> void zip(A<0> *ap, T);
void zap() { zip(0, 0); }

template <int ...N, typename T DEFAULT_ARG> void foo(A<N> *..., T);
void bar() { foo<0>(0, 0); }


### COMPILER INVOCATION:
clang -cc1 -std=c++11 -x c++ -


### ACTUAL OUTPUT:
<stdin>:13:14: error: no matching function for call to 'foo'
void bar() { foo<0>(0, 0); }
             ^~~~~~
<stdin>:12:50: note: candidate template ignored: couldn't infer template
argument 'T'
template <int ...N, typename T DEFAULT_ARG> void foo(A<N> *..., T);
                                                 ^
1 error generated.


### EXPECTED OUTPUT:
Clean compile.


### COMPILER VERSION INFO:
clang version 3.7.0 (trunk 232493) (llvm/trunk 232485)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Candidate multilib: .;@m64
Selected multilib: .;@m64</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>