This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/4205: function template can call other function with incorrect parameters



>Number:         4205
>Category:       c++
>Synopsis:       function template can call other function with incorrect parameters
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 02 10:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jens Maurer
>Release:        gcc 3.0.1
>Organization:
>Environment:
Linux 2.4.8 with glibc 2.2.3
>Description:
The attached code should give an error at least in the
call to foo(&wibble), because you can't call wibble() with
just one argument, but these gcc versions don't:

gcc version 3.0.1
gcc version 3.1 20010901 (experimental)
gcc version 2.95.3 20010315 (release)
>How-To-Repeat:

// Douglas Gregor on boost 2001-08-22

#include <iostream>

template<typename F>
void foo(F f)
{
  f(1);
}

void bar(int i, int j = 5, int k = 7)
{
  std::cout << "bar(" << i << ", " << j << ", " << k << ")" << std::endl;
}

void wibble(int i, int j, int k = 9)
{
  std::cout << "wibble(" << i << ", " << j << ", " << k << ")" << std::endl;
}

int main()
{
  foo(&bar); 
  foo(&wibble); // should give an error, "wibble" cannot be called with one arg
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]