Bug 431686 - Error on template expansion with function with default argument
Error on template expansion with function with default argument
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
i386 Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-06 09:31 EST by Horst H. von Brand
Modified: 2008-02-06 12:00 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-02-06 10:38:51 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
A C++ file that shows the error (159 bytes, text/plain)
2008-02-06 09:31 EST, Horst H. von Brand
no flags Details
Another testcase (223 bytes, text/plain)
2008-02-06 10:28 EST, Horst H. von Brand
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 32839 None None None Never

  None (edit)
Description Horst H. von Brand 2008-02-06 09:31:36 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):
gcc-c++-4.3.0-0.7.i386

How reproducible:
Always

Steps to Reproduce:
1. Compile the attached file
2.
3.
  
Actual results:
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

Expected results:
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.

Additional info:
Comment 1 Horst H. von Brand 2008-02-06 09:31:36 EST
Created attachment 294106 [details]
A C++ file that shows the error
Comment 2 Jakub Jelinek 2008-02-06 09:51:50 EST
That's a bug in the testcase.
See http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01645.html and
http://gcc.gnu.org/PR32839
Comment 3 Horst H. von Brand 2008-02-06 10:26:34 EST
I'm sorry, but that doesn't look right.

  int f(int i = 117);

has what type? int (*)() or int (*)(int)?

If I go:

  int f();
  int f(int);

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
(which matches).
Comment 4 Horst H. von Brand 2008-02-06 10:28:01 EST
Created attachment 294113 [details]
Another testcase

How come callf() gives an error, while the completely equivalent callg() goes
through?
Comment 5 Jakub Jelinek 2008-02-06 10:38:51 EST
If you want to argue about this, do so upstream in the PR I referenced.
I'm not convinced you are right.
Comment 6 Horst H. von Brand 2008-02-06 12:00:43 EST
Reported as 35106 on GCC's bugzilla

Note You need to log in before you can comment on or make changes to this bug.