This code: template<typename T> void foo(int i, void(*f)(T*) = 0, T* a = 0) {} int main() { foo(5); return 0; }
gets you: foo.cc: In function int main(): foo.cc:5: error: no matching function for call to foo(int) So I figured that binding required an actual type, so I tried making it explicit in the default values: template<typename T> void foo(int i, void(*f)(T*) = static_cast<void(*)(void*)>(0), T* a = static_cast<void*>(0)) {} int main() { foo(5); return 0; } But that gets me the same error. I'm not sure whether argument types can be bound from default arguments in the standard, but if they can't then I should get a diagnostic at the declaration of the template. The actual message is cryptic and unhelpful. -- Summary: Fails to identify template function with default args Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: igodard at pacbell dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40127