https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84893

            Bug ID: 84893
           Summary: Rejects a valid code with variadic function template
                    taking a function pointer
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: v.reshetnikov at gmail dot com
  Target Milestone: ---

The following C++ code is rejected by GCC 8.0.1 20180313 (tested with
https://godbolt.org/):

/************* SOURCE *************/
template<typename... T>
void f(void(*)(T..., int)) { }

void g(bool, int) { }

int main() {
    f<bool>(g);
}
/*********** END SOURCE ***********/


/************* OUTPUT *************/
<source>: In function 'int main()':
<source>:7:14: error: no matching function for call to 'f<bool>(void (&)(bool,
int))'
     f<bool>(g);
              ^
<source>:2:6: note: candidate: 'template<class ... T> void f(void (*)(T ...,
int))'
 void f(void(*)(T..., int)) { }
      ^
<source>:2:6: note:   template argument deduction/substitution failed:
<source>:7:14: note:   mismatched types 'int' and 'bool'
     f<bool>(g);
              ^
Compiler returned: 1
/*********** END OUTPUT ***********/

I believe the code is valid and should be compiled successfully.

Reply via email to