When I try to compile the code below, g++ reports "error: assuming cast to type 'bool (*)(evaluator&)' from overloaded function" on the line indicated. I have isolated the comparison to the pointer to the template function "stop" as the source of the problem. Is this the correct behavior?
#include <iostream> struct evaluator { bool (*eval)(evaluator&); }; template <typename T> bool stop(T &e) { return true; } bool eval(evaluator &e) { return true; } int main() { typedef bool (*evalf)(evaluator&); struct evaluator e = { stop<evaluator> }; // error: assuming cast to type 'bool (*)(evaluator&)' from // overloaded function std::cout << (e.eval == stop<evaluator>) << '\n'; // ok--eval is not templated std::cout << (e.eval == eval) << '\n'; // ok--explicitly cast to correct type std::cout << (e.eval == static_cast<evalf>(stop<evaluator>)) << '\n'; return 0; } I compiled this using the MinGW port of g++ 3.4.2 on W2kSP4. I unfortunately do not have easy access to g++ 4.1.1, however Kai-Uwe Bux reports the same result from that version via comp.lang.c++ (discussion archived at http://groups.google.com/group/comp.lang.c++/browse_frm/thread/b25fee316ec891b6). -- Summary: Comparison with Pointer to Template Function Requires Explicit Cast Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: justin dot piper at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29187