Bug 37088 - Functions with default parameters not correctly handled inside templates.
Summary: Functions with default parameters not correctly handled inside templates.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 39136 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-11 22:39 UTC by Sriraman Tallam
Modified: 2009-02-10 22:03 UTC (History)
3 users (show)

See Also:
Host: x86_64
Target: x86_64
Build: x86_64
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sriraman Tallam 2008-08-11 22:39:01 UTC
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
Comment 1 Andrew Pinski 2008-08-11 22:45:21 UTC
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.
Comment 2 Wolfgang Bangerth 2008-08-13 16:21:31 UTC
(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.
Comment 3 Andrew Pinski 2009-02-10 22:03:41 UTC
*** Bug 39136 has been marked as a duplicate of this bug. ***