[Bug c++/49609] No code emitted for address-taken instances of function templates
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jul 1 18:56:00 GMT 2011
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));
More information about the Gcc-bugs
mailing list