This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49609] No code emitted for address-taken instances of function templates
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 1 Jul 2011 18:56:40 +0000
- Subject: [Bug c++/49609] No code emitted for address-taken instances of function templates
- Auto-submitted: auto-generated
- References: <bug-49609-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49609
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-07-01 18:56:19 UTC ---
(In reply to comment #3)
> That's a pretty strained reading. Even if that were pedantically what the
> standard says, it would clearly be an oversight.
ok, good! I would have assumed it was meant to work except that clang gives
exactly the same behaviour, so I started looking for reasons why.
(In reply to comment #4)
> > You can also make it work by not specifying an explicit template argument list
> > and letting them be deduced:
> >
> > void *(*my_function_ptr)(void*, void *)
> > = reinterpret_cast<void*(*)(void*,void*)>(
> > (void*(*)(float*,float*))&value_convert_function);
>
> Cool -- thanks for this! That teaches me for thinking I can get away without
> ever using C-style casts in C++....
You can do it without -style casts, using static_cast:
void *(*my_function_ptr)(void*, void *)
= reinterpret_cast<void*(*)(void*,void*)>(
static_cast<void*(*)(float*,float*)>(&value_convert_function));
or with a functional-style cast:
typedef void*(*func_type)(float*,float*);
void *(*my_function_ptr)(void*, void *)
= reinterpret_cast<void*(*)(void*,void*)>(
func_type(&value_convert_function));