This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/4411: g++ 3.0 doesn't find matching template function
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/4411: g++ 3.0 doesn't find matching template function
- From: cppx <cppx at swag dot uwaterloo dot ca>
- Date: Thu, 27 Sep 2001 10:35:39 -0400
>Number: 4411
>Category: c++
>Synopsis: g++ 3.0 doesn't find matching template function
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Sep 27 07:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Andrew Malton
>Release: gcc version 3.0
>Organization:
University of Waterloo
>Environment:
System: Linux swag.uwaterloo.ca 2.2.17 #2 SMP Thu Dec 14 20:12:03 EST 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0/configure --prefix=/home/cppx/gcc-3.0/install/
>Description:
A situation arises in which g++ fails to find a matching function call.
It apparently requires the interaction of
(a) template function
(b) with template argument which is a function type
(c) and with pointer to member parameter
In so far as removing the template header, changing the template argument to a
data type, or changing the parameter to something which isn't a pointer-to-member,
make the problem go away (i.e. the same code is accepted).
The error is "no matching function for call to `f (int (B::*)())".
>How-To-Repeat:
The following code illustrates the problem:
typedef int T ();
struct B {T h;};
template <class T> void f (T B::*);
void g () { f<T> (&B::h); }
(But removing the template works fine, as in
typedef int T ();
struct B {T h;};
void f (T B::*);
void g () { f (&B::h); }
(and using a data type instead of a function type for T works fine, as in
typedef int (*T) ();
struct B {T h;};
template <class T> void f (T B::*);
void g () { f<T> (&B::h); }
(and dropping the pointer-to-member works fine, as in
typedef int T ();
T h;
template <class T> void f (T*);
void g () { f<T> (&h); }
(and I hope this pinpoints the issue, assuming it isn't all an obscure infraction.)
>Fix:
The easiest workaround is not instantiating f with a function type, but use a pointer to
function type instead.
>Release-Note:
>Audit-Trail:
>Unformatted: