[Bug c++/53506] Variadic templates in combination with function pointer problem

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Aug 20 18:55:00 GMT 2017


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-20
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
gcc8's output has added carets:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -std=c++11 53506.cc
53506.cc: In function ‘int main()’:
53506.cc:17:17: error: no matching function for call to ‘A<int>::a(int (&)(int,
int), int)’
  A<int>::a(foo,0);
                 ^
53506.cc:5:2: note: candidate: ‘template<class RES, class ... FARGS> static
void A<SARGS>::a(RES (*)(FARGS ..., SARGS ...), FARGS ...) [with RES = RES;
FARGS = {FARGS ...}; SARGS = {int}]’
  a(RES(*func)(FARGS...,SARGS...),FARGS...)
  ^
53506.cc:5:2: note:   template argument deduction/substitution failed:
53506.cc:17:17: note:   candidate expects 1 argument, 2 provided
  A<int>::a(foo,0);
                 ^
53506.cc:18:26: error: no matching function for call to ‘A<int>::a<int,
int>(int (&)(int, int), int)’
  A<int>::a<int,int>(foo,0);
                          ^
53506.cc:5:2: note: candidate: ‘template<class RES, class ... FARGS> static
void A<SARGS>::a(RES (*)(FARGS ..., SARGS ...), FARGS ...) [with RES = RES;
FARGS = {FARGS ...}; SARGS = {int}]’
  a(RES(*func)(FARGS...,SARGS...),FARGS...)
  ^
53506.cc:5:2: note:   template argument deduction/substitution failed:
53506.cc:18:26: note:   candidate expects 1 argument, 2 provided
  A<int>::a<int,int>(foo,0);
                          ^
$

For comparison, clang only errors once:

$ /sw/opt/llvm-3.1/bin/clang++ -c -Wall -Wextra -pedantic -std=c++11 53506.cc
53506.cc:5:9: warning: unused parameter 'func' [-Wunused-parameter]
        a(RES(*func)(FARGS...,SARGS...),FARGS...)
               ^
53506.cc:18:2: error: no matching function for call to 'a'
        A<int>::a<int,int>(foo,0);
        ^~~~~~~~~~~~~~~~~~
53506.cc:5:2: note: candidate template ignored: failed template argument
deduction
        a(RES(*func)(FARGS...,SARGS...),FARGS...)
        ^
1 warning and 1 error generated.
$

So, confirmed that g++ errors more than might be expected.


More information about the Gcc-bugs mailing list