<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121381>121381</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] template class with default non-type parameter is never matched in return type of function with variadic template parameter
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wangbo15
      </td>
    </tr>
</table>

<pre>
    The following valid program is rejected by Clang:

```c++
template<typename T1, int T2 = 0>
struct tuple {};

template<typename... Args>
tuple<Args...> foo(){
    return tuple<Args...>{}; 
}

int main()
{
  foo<int>();
}
```

The code can normally compile if the default template parameter of `tuple` does not exist.

GCC, MSVC, and EDG all accept it.

clang rejects it with:

```c++
<source>:11:3: error: no matching function for call to 'foo'
   11 |   foo<int>();
      | ^~~~~~~~
<source>:5:16: note: candidate template ignored: substitution failure [with Args = <int>]: template argument for non-type template parameter must be an expression
    5 | tuple<Args...> foo(){
      | ~~~~~ ^
1 error generated.
```

Please see https://godbolt.org/z/6h8vWx47x
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVEGPszYQ_TXmMlpk7BDCgQNLNt-pUqWu2rPBA7gyNrJNdreH_vbKOJtI3W31IUtEsef5zXuPEd6rySA2pHwm5TkTW5ita96EmXpblFlv5UfzOiOMVmv7pswEV6GVhNXZyYkFlAeHf-IQUEL_AZ0WZiK8JXRfR5rWQNhzXLQNuKxaBCS8Cx8rGrEgvBaEdaBMgFcGhJ-BEv5CaOuD24YAYVs1AqmeSXUm_DlBf4OT5zm0bvKpeK8ivIv_5HlO-AuM1hJ2IqyOWLQFAHAYNmfg6-H7dRDvq87p1shxEcrcYOJOQorQvFMmxNK0mZimyk8dEkrUc7ASYRAGjHWL0PoDBrusSiOoEcKMIHEUmw7w2SiswokFAzqwI5AjTZyPFKRFD8YGwHflQ57u-NF1UdRff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