https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125181
Bug ID: 125181
Summary: GCC rejects passing function pointer as argument to
variadic function template parameter with const
parameter
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
I wrote the following program that is accepted by clang and msvc but rejected
by gcc. Demo:https://godbolt.org/z/5rMErY6ro
```
template<typename... T> double BigFunction(double (*func)(const T...), double
var)
{
return {};
}
double f3(double, int)
{
return {};
}
int main()
{
BigFunction(f3, 3);// GCC: no but Clang + MSVC: ok
}
```
GCC says:
```
<source>: In function 'int main()':
<source>:15:16: error: no matching function for call to 'BigFunction(double
(&)(double, int), int)'
15 | BigFunction(f3, 3);// GCC: no but Clang + MSVC: ok
| ~~~~~~~~~~~^~~~~~~
• there is 1 candidate
• candidate 1: 'template<class ... T> double BigFunction(double (*)(const T
...), double)'
<source>:3:32:
3 | template<typename... T> double BigFunction(double (*func)(const
T...), double var)
| ^~~~~~~~~~~
• template argument deduction/substitution failed:
• types 'const T' and 'double' have incompatible cv-qualifiers
<source>:15:16:
15 | BigFunction(f3, 3);// GCC: no but Clang + MSVC: ok
| ~~~~~~~~~~~^~~~~~~
ASM generation compiler returned: 1
<source>: In function 'int main()':
<source>:15:16: error: no matching function for call to 'BigFunction(double
(&)(double, int), int)'
15 | BigFunction(f3, 3);// GCC: no but Clang + MSVC: ok
| ~~~~~~~~~~~^~~~~~~
• there is 1 candidate
• candidate 1: 'template<class ... T> double BigFunction(double (*)(const T
...), double)'
<source>:3:32:
3 | template<typename... T> double BigFunction(double (*func)(const
T...), double var)
| ^~~~~~~~~~~
• template argument deduction/substitution failed:
• types 'const T' and 'double' have incompatible cv-qualifiers
<source>:15:16:
15 | BigFunction(f3, 3);// GCC: no but Clang + MSVC: ok
| ~~~~~~~~~~~^~~~~~~
```