<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61129>61129</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang issue/question: call to func with variadic templates is ambiguous
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
samuelpmish
</td>
</tr>
</table>
<pre>
Hi,
the following code fails to compile with clang:
```cpp
template < int ... dimensions >
struct tensor{};
template < int m, int n >
void foo(tensor< m >, tensor < m, n >);
template < int m, int n, int ... rest >
void foo(tensor< m >, tensor < m, n, rest ... >);
int main() {
tensor< 2 > a;
tensor< 2, 3 > b;
// error: call to 'foo' is ambiguous
// note: candidate function [with m = 2, n = 3]
// void foo(tensor< m >, tensor < m, n >);
//
// note: candidate function [with m = 2, n = 3, rest = <>]
// void foo(tensor< m >, tensor < m, n, rest ... >);
foo(a, b);
}
```
I would have guessed that the first overload is preferable, so there would be no ambiguity. MSVC and gcc compile it without problems, with ties going to the non-variadic overload (https://godbolt.org/z/dTsv5q6Pq).
I don't know the precise wording of the standard on this, so it's unclear to me if this is an issue with clang, or an issue with MSVC and gcc, but I thought I'd post it here to find out more information.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVV2PqzYQ_TXmZXQRmISPBx52k0bdh0qVWvXdYANujYe1h0S3v76yyW4-blVVvZVWrIM958w5Mx6E93q0SrVs_8r2x0SsNKFrvZhXZZZZ-ynpUH5tf9SMH1h2ZNnL9qRJwYDG4EXbEXqUCgahjQdC6HFetFFw0TRBb4QdWfFyH8zKbPvrl-UKp-bFCFLAigNoS5CmKUg9K-s1Wg-s-GE76MmtPQEp69Gx6pVVR1a8PmT2DDUzvi3sDeaMWsKAyHh9hSoOMMd9friiR4AYvAXy5t8zfSyCDKc8_Wfm8IgAAelvs4jEQlvGa8YbCJ7E9wAANwYegkF8xt5vBY4i7ndP2AGD8RPjJ1DOheMv0AtjQpUZr6KMCrQHMXd6XHH138RZJLWFWallcGtYbU8aLbD9a2yRoP64pWHjsmD74zdA31myG9L_lOJHYcIvVhwC3fdn_U_lDqgbkgjHuodWqI5PV-u-jG9wwdVImMRZwbgq75UEmgRBvMbaeQI8K2dQyFDNxalBOdEZFYg8hmNOXUE6BRavBdf0NYWffvntAMJKGPv-8-5ritcfV4LFYWfU7ANWNJO08jBiGBwUscGi_XIWTgup-1smjNcT0eLD9Ihujig7NJSiGxk__cn4Sf7qz_v38ud3xpv0UbJEy3hF8IfFSyRZnOq1DzKcDNw4xNeehJXCSUALNGl_layJ8crDanujhAuJzgr0EI_EjregvV8fphw_ALqnnXt3YtlWgjcIzowTwRvjlYQFPQXHosuEMGgrIVg3o1Og7YBuFqEf00S2hWyKRiSqzcuqquoy35XJ1NayL4ZM8LyqyqGsh7Kp8mo35EMhy3q_rxPd8owXWZHxvNlxXqZiz-umy7uiGfK-Giq2y9QstEmNOc_B4iSqaMs8501iRKeMj58Jzq26bBIZ5-Gr4doQ86VbR892mdGe_A2FNBnVHoJBH0Gn91X5oOd-noQ7t1n22QkfA9Y_jJhkdaZ9agxN09qlPc6MnwLz9d-XxeHvqifGT5HaM36Kev4KAAD__30fGBQ">