For this simple program (test.cc): ------------------------------------------------------------------------- template <typename Pred> void AssertPred(Pred pred) { pred("x", "y"); } bool pred4(const char *, const char *, const char *x = "", const char *y = ""); bool pred2(const char *, const char *); void foof() { AssertPred(pred2); AssertPred(pred4); } ----------------------------------------------------------------------------- > $gcc421 -c test.ii (Success with gcc-4.2.1) > $gcc431 -c test.ii (Failure with gcc-4.3.1) test.ii: In function 'void AssertPred(Pred) [with Pred = bool (*)(const char*, const char*, const char*, const char*)]': test.ii: instantiated from here test.ii: error: too few arguments to function
Hmm, I don't think default parameters are taken into account with function pointers. I think this was a GCC "undocumented extension" (aka bug) that was fixed in 4.3.
(In reply to comment #0) > bool pred4(const char *, const char *, const char *x = "", const char *y = ""); The type of pred4 is still bool (*) (const char *, const char *, const char *x, const char *) and so when you pass this function through a pointer it can't be called with only two parameters. Andrew is right that this used to be one of the many ill-conceived gcc extensions. W.
*** Bug 39136 has been marked as a duplicate of this bug. ***