[Bug c++/53506] New: Variadic templates in combination with function pointer problem
o.mangold at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Mon May 28 09:09:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53506
Bug #: 53506
Summary: Variadic templates in combination with function
pointer problem
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: o.mangold@googlemail.com
The example code below appears to be correct to me, but does not compiler with
g++. I tried it also with Intel compiler 12.1, and icc compiles it just fine.
Neither the first, nor the second version of the call of a() seems to work. It
can't deduce the template args from the function pointer and also does not
accept explicit specification. I had expected at least the second version of
the call to work. Is gcc wrong here or icc?
> icpc -strict-ansi -std=c++0x fpointers.cxx
> g++ -std=c++11 fpointers.cxx
fpointers.cxx: In function ‘int main()’:
fpointers.cxx:17:18: error: no matching function for call to ‘A<int>::a(int
(&)(int, int), int)’
fpointers.cxx:17:18: note: candidate is:
fpointers.cxx:5:3: note: template<class RES, class ... FARGS> static void
A::a(RES (*)(FARGS ..., SARGS ...), FARGS ...) [with RES = RES; FARGS = {FARGS
...}; SARGS = {int}]
fpointers.cxx:5:3: note: template argument deduction/substitution failed:
fpointers.cxx:17:18: note: candidate expects 1 argument, 2 provided
fpointers.cxx:18:27: error: no matching function for call to ‘A<int>::a(int
(&)(int, int), int)’
fpointers.cxx:18:27: note: candidate is:
fpointers.cxx:5:3: note: template<class RES, class ... FARGS> static void
A::a(RES (*)(FARGS ..., SARGS ...), FARGS ...) [with RES = RES; FARGS = {FARGS
...}; SARGS = {int}]
fpointers.cxx:5:3: note: template argument deduction/substitution failed:
fpointers.cxx:18:27: note: candidate expects 1 argument, 2 provided
--- fpointers.cxx ---
template<typename... SARGS>
struct A
{
template<typename RES,typename... FARGS> static void
a(RES(*func)(FARGS...,SARGS...),FARGS...)
{
}
};
int foo(int,int)
{
return 0;
}
int main()
{
A<int>::a(foo,0);
A<int>::a<int,int>(foo,0);
return 0;
}
More information about the Gcc-bugs
mailing list