c++/3784: function not found...

Nathanael Nerode neroden@twcny.rr.com
Fri Jan 3 05:26:00 GMT 2003


The following reply was made to PR c++/3784; it has been noted by GNATS.

From: Nathanael Nerode <neroden@twcny.rr.com>
To: gcc-gnats@gcc.gnu.org, holt@gholt.net, nathan@gcc.gnu.org,
   gcc-bugs@gcc.gnu.org
Cc:  
Subject: Re: c++/3784: function not found...
Date: Fri, 3 Jan 2003 00:21:12 -0500

 I started to track this down. The failure comes from call.c in 
 build_new_function_call somewhere around line 2717, when the call to 
 add_template_candidate fails to add anything.
 
 I put in a dump_node(t,0,stdout) just before the call.
 
 In the working cases, the first node is the template_decl for foo2.  It's 
 chained to the template_decl for X.
 
 In the broken case, it's chained to the template_decl for foo1, which is
 chained to the template_decl for X.
 @4      template_decl    name: @10      type: @3       srcp: test.cxx:3
                          chan: @11      rslt: @12      prms: @13
 @10     identifier_node  strg: foo1     lngt: 4
 
 I'm pretty sure this is wrong.  The tree we're looking at here is, I believe, 
 supposed to be for one overloaded function (foo2).  What does this have to do 
 with foo1?  Nothing.
 
 (Of course it's also possible that add_template_candidate should be able to 
 deal with this properly; I don't think that's the origin of the bug, though.)
 
 First working case:
 --
 template <typename T, unsigned N> class X { };
 
 // template <typename T, int N>       void foo1(X<T,N>);
 template <typename T, unsigned N>  void foo2(X<T,N>);
 
 int main() {
   X<float, 2> x;
   foo2(x);
 }
 --
 
 Second working case:
 --
 template <typename T, unsigned N> class X { };
 
 
 template <typename T, unsigned N>  void foo2(X<T,N>);
 template <typename T, int N>       void foo1(X<T,N>);
 
 int main() {
   X<float, 2> x;
   foo2(x);
 }
 --
 Note that this second case gives *exactly* the same tree dump as the first 
 working case, with no mention of foo1 at all.  Interesting, no?  Whether foo1 
 should be in this tree or not, it should be the same regardless of order of 
 declaration.  This example is why I suspect foo1 shouldn't be in this tree 
 (of course, I could be wrong, and this could be a case of one bug hiding 
 another).
 
 The broken case:
 --
 template <typename T, unsigned N> class X { };
 
 template <typename T, int N>       void foo1(X<T,N>);
 template <typename T, unsigned N>  void foo2(X<T,N>);
 
 
 int main() {
   X<float, 2> x;
   foo2(x);
 }
 --
 
 Next step is to try to figure out why this tree includes foo1 when it 
 shouldn't...



More information about the Gcc-prs mailing list