<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 --- - Variadic template function fails to match forward-declared template with default values"
   href="http://llvm.org/bugs/show_bug.cgi?id=20890">20890</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Variadic template function fails to match forward-declared template with default values
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>schrodingersbox@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=13014" name="attach_13014" title="Source file which fails to compile due to bug">attachment 13014</a> <a href="attachment.cgi?id=13014&action=edit" title="Source file which fails to compile due to bug">[details]</a></span>
Source file which fails to compile due to bug

A function with a variadic template template argument fails to match against a
template class whose default template arguments are forward-declared. For
example the following code fails to compile:

template<typename A, typename B> struct foo;
template<typename A, typename B=int> struct foo { };

template <template <typename, typename...> class Container>
void processVariadic(Container<double> /*elements*/) { }

int main() {
    processVariadic(foo<double>{});
}

Compiling with 'clang++ -std=c++11 bug.cpp', the resulting error is:

bug.cpp:8:5: error: no matching function for call to 'processVariadic'
    processVariadic(foo<double>{});
    ^~~~~~~~~~~~~~~
bug.cpp:5:6: note: candidate template ignored: substitution failure [with
Container = foo]:
      too few template arguments for class template 'foo'
void processVariadic(Container<double> /*elements*/) { }
     ^               ~~~~~~~~~
1 error generated.

The compiler seems to look at the first declaration and expect foo to require
two template parameters, ignoring the later default parameter. If the default
parameter is instead put on the forward declaration, it compiles fine.

Both clang++ 3.6.0 (trunk) and Apple LLVM version 5.1 (clang-503.0.40) (based
on LLVM 3.4svn) fail to compile. GCC (g++ 4.9.1) is able to compile properly.

This issue occurs, for example, in the libc++ implementation of std::list.</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>