This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53506] New: Variadic templates in combination with function pointer problem
- From: "o.mangold at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 28 May 2012 08:48:06 +0000
- Subject: [Bug c++/53506] New: Variadic templates in combination with function pointer problem
- Auto-submitted: auto-generated
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;
}