Bug 4908

Summary: Pointer to function type template arguments include default argument info
Product: gcc Reporter: jajarvi
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bangerth, gcc-bugs, lerdsuwa, pinskia
Priority: P3 Keywords: accepts-invalid
Version: 3.0.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-01-01 01:59:54

Description jajarvi 2001-11-19 13:56:00 UTC
 Function default arguments should not be part of the pointer to 
 function type. However, when a type template parameter is instantiated
 with a pointer to function, information about default arguments seem
 to lurk in somewhat strangely.

 The following code compiles and runs:
        void foo(int i=1);
        template<class F> void call(F f) { f(); }

        The test program in the How-To-Repeat part is self explaining

Release:
3.0.2

Environment:
System: SunOS trillian.osl.iu.edu 5.8 Generic_108528-09 sun4u sparc SUNW,Sun-Blade-100
Architecture: sun4

 
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ./configure --prefix=/l/gcc302

How-To-Repeat:
#include <iostream>

using namespace std;

void foo(int i = 1) { cout << "foo " << i << endl; } 

void bar(int i) { cout << "bar " << i << endl; } 

template <class F>
void call(F f, F g) { f(); g(); }

int main() {

  call(&foo, &bar);
  return 0;

}
Comment 1 Kriang Lerdsuwanakij 2002-06-08 07:51:26 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.  The code should not compile.
Comment 2 Wolfgang Bangerth 2002-06-10 10:31:23 UTC
From: Wolfgang Bangerth <bangerth@math.ethz.ch>
To: lerdsuwa@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
        <gcc-gnat@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>, <jajarvi@osl.iu.edu>
Cc:  
Subject: Re: c++/4908: Pointer to function type template arguments include
 default argument info
Date: Mon, 10 Jun 2002 10:31:23 +0200 (CEST)

 Just for reference, this bug may be related to c++/2862 and c++/2863, 
 which also take default parameters into the function signature.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth                 email:            bangerth@math.ethz.ch
                                   www: http://www.math.ethz.ch/~bangerth/
Comment 3 Dara Hazeghi 2003-07-11 23:18:57 UTC
Still present on branch and mainline (not fixed by new parser) (20030710).
Comment 4 Eric Botcazou 2003-09-08 07:39:21 UTC
Generic C++ front-end problem.
Comment 5 Andrew Pinski 2004-01-03 12:54:51 UTC
This is a dup of bug 4205.

*** This bug has been marked as a duplicate of 4205 ***