<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67172>67172</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang fails to deduce parameter pack for a function pointer's arguments if there are arguments after the pack
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jeremy-rifkin
</td>
</tr>
</table>
<pre>
Clang fails to compile the following code
```cpp
int foo(int, float, void*);
template<typename R, typename... Args>
R wrap(R(*fun)(Args..., void*), Args&&... args) {
return fun(std::forward<Args>(args)..., nullptr);
}
void bar() {
wrap(foo, 1, 2.2f);
}
```
```
<source>:11:5: error: no matching function for call to 'wrap'
11 | wrap(foo, 1, 2.2f);
| ^~~~
<source>:6:3: note: candidate template ignored: could not match 'void *' against 'int'
6 | R wrap(R(*fun)(Args..., void*), Args&&... args) {
| ^
1 error generated.
```
This is ostensibly valid code. `Args...` in the declaration of fun should be a non-deduced context and the arguments should be deduced correctly as far as I can tell https://eel.is/c++draft/temp.deduct.type#5.7.
https://godbolt.org/z/sjnbTzW3b
GCC and MSVC also fail to compile this. There is an issue for GCC here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56190.
Clang successfully compiles this code if given `R`
```cpp
void bar() {
wrap<int>(foo, 1, 2.2f);
}
```
There is 100% buggy behavior somewhere here.
https://godbolt.org/z/v7n8cYrKe
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU1v4zYQ_TX0ZRBBIm3JPvjgKOuiKHpJFy16KihyKHGXIgWScuo95LcXpOzESYNFW6CAYX1xhm_emzfkIejeIu7J5p5sHlZ8joPz-y_ocTzfea2-arvqnDzvW8NtD4prEyA6EG6ctEGIA4JyxrgnbXsQTiIpH0h5uPzX5fIT07S80TaCco7QrbaR0BaUcTzfnJyWhB4I3RF2f5sk4jgZHpGwNp4ntHxEeEwR16eiKODg-0DYp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