Bug 10845

Summary: [3.3/3.4 regression] template member function (getting a nested template as parameter) cannot be called anymore if another unrelated template member function is defined.
Product: gcc Reporter: have
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, giovannibajo
Priority: P3 Keywords: rejects-valid
Version: 3.3   
Target Milestone: 3.3.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description have 2003-05-18 17:56:00 UTC
error: no matching function for call to `A<int>::f(int&, A<int>::SubA<int>&)'. 

In what follows, words written as _underscored_ mean that without any _underscored_ hypothesis, bug does not occur.

Let us consider a method f (with _two_ templates arguments) of a _template_ class A. 
The first argument is given by a _template T1_.
The second argument is given as a _template_ sub class of A (SubA<L>) and the second template typename of f is given for matching L.
Moreover, there exists (at least) another template method in A which has the same argument type than the second one of f.
Then f cannot be found when it is called.

Release:
g++-3.2, 3.3

Environment:
Linux i686

How-To-Repeat:
Try to compile this code
---8<------------
template<typename T>
struct A {
  template<typename L> struct SubA { };

  template<typename T1,typename L> void f(T1 & t1, SubA<L> & t2) { }
  template<typename U> void g(SubA<U> & suba) { }
  template<typename U> void h(SubA<U> & suba) { }
};

int main(void) {
  int i;
  A<int> a;
  A<int>::SubA<int> suba;

  a.f(i,suba);
  a.g(suba);
  a.h(suba);
}
Comment 1 Giovanni Bajo 2003-05-18 19:51:45 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. The funny thing about this bug is that if you
    remove the member functions g() and h(), the call to f()
    succeeds.
    I rate this as a regression because the above snippet
    without h() compiles with 2.95 but fails on 3.x. The snippet
    provided by the poster fails also with 2.95, but it's the
    opposite problem: it manages to call f() but not g() and 
    h().
Comment 2 CVS Commits 2003-06-20 15:48:30 UTC
Subject: Bug 10845

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-06-20 15:44:25

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: member3.C 

Log message:
	PR c++/10845
	* pt.c (try_class_unification): Correct handling of member class
	templates.
	
	* semantics.c (genrtl_finish_function): Adjust
	expand_function_end call.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3443&r2=1.3444
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.703&r2=1.704
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2784&r2=1.2785
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/member3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 Mark Mitchell 2003-06-20 15:55:57 UTC
Fixed in GCC 3.3.1, GCC 3.4.