This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/49609] No code emitted for address-taken instances of function templates


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));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]