Red Hat Bugzilla – Bug 431686
Error on template expansion with function with default argument
Last modified: 2008-02-06 12:00:43 EST
Description of problem:
Compiling the attached file gives an error with g++ 4.3, but the same worked
fine with 4.1. This is cut down from
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Compile the attached file
tst.cc: In function ‘void ff(int, T) [with T = void (*)(int, int)]’:
tst.cc:13: instantiated from here
tst.cc:4: error: too few arguments to function
No error, realf() can be called with one or two arguments. AFAIU the default
value of the second argument is just a shorthand for an overload of the function.
Created attachment 294106 [details]
A C++ file that shows the error
That's a bug in the testcase.
See http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01645.html and
I'm sorry, but that doesn't look right.
int f(int i = 117);
has what type? int (*)() or int (*)(int)?
If I go:
what is the type of f? I'd say this is ambiguous, to say the least.
Besides, gcc-4.1 did do "the right thing", i.e., consider the first alternative
Created attachment 294113 [details]
How come callf() gives an error, while the completely equivalent callg() goes
If you want to argue about this, do so upstream in the PR I referenced.
I'm not convinced you are right.
Reported as 35106 on GCC's bugzilla