http://gcc.gnu.org/bugzilla/show_bug.cgi?id=99
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dodji at gcc dot gnu.org --- Comment #22 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Manuel López-Ibáñez from comment #21) > (In reply to Christian Ehrhardt from comment #5) > > From: "Christian Ehrhardt" <ehrha...@mathematik.uni-ulm.de> > > To: gcc-gn...@gcc.gnu.org, gcc-bugs@gcc.gnu.org, ca...@alinoe.com, > > g...@gcc.gnu.org, gcc-...@gcc.gnu.org, mar...@loewis.home.cs.tu-berlin.de > > Cc: > > Subject: Re: c++/99: [2003-03-26] Bug in type in error message. > > Date: Tue, 6 May 2003 15:04:23 +0200 > > > > Here's a further reduced testcase, along with some more analysis: > > > > template<typename S> class X {}; > > template<typename Q> int f(X<int>, X<Q>); > > template<typename B> int f(X<B>, X<int>); > > > > int main(void) { > > return f(X<int>(), X<int>()); > > } > > > > For this testcase, the problem is that: > > (gdb) p debug_tree(arglist) > <tree_vec 0x7ffff7570d40 > elt 0 <template_type_parm 0x7ffff7566348 Q VOID > align 8 symtab 0 alias set -1 canonical type 0x7ffff7566150 > index 0 level 1 orig_level 1 > chain <type_decl 0x7ffff755fc38 Q>>> > > and > > (gdb) p debug_tree(arglist) > <tree_vec 0x7ffff7570e60 > elt 0 <template_type_parm 0x7ffff7566690 B VOID > align 8 symtab 0 alias set -1 canonical type 0x7ffff7566150 > index 0 level 1 orig_level 1 > chain <type_decl 0x7ffff755ff18 B>>> > > have the same hash: > > (gdb) p hash > $128 = 3284467468 > > I am not sure whether we should change the hashing function or whether we > should add some additional check. But what kind of check? And this triggers also with simple typedefs: template<typename S> class X {}; template<typename Q> int f(X<int>, X<Q>); template<typename B> int f(X<B>, X<myint>); int foo(void) { return f(X<int>(), X<int>()); } gives: /home/manuel/test1/pr99.cc:8:30: error: call of overloaded ‘f(X<int>, X<int>)’ is ambiguous return f(X<int>(), X<int>()); ^ /home/manuel/test1/pr99.cc:8:30: note: candidates are: /home/manuel/test1/pr99.cc:4:26: note: int f(X<int>, X<Q>) [with Q = int] template<typename Q> int f(X<int>, X<Q>); ^ /home/manuel/test1/pr99.cc:5:26: note: int f(X<Q>, X<int>) [with B = int] template<typename B> int f(X<B>, X<myint>); ^ Perhaps the only solution is to not pretty-print the candidates, which is exactly what clang does: pr99.cc:8:10: error: call to 'f' is ambiguous return f(X<int>(), X<int>()); ^ pr99.cc:4:26: note: candidate function [with Q = int] template<typename Q> int f(X<int>, X<Q>); ^ pr99.cc:5:26: note: candidate function [with B = int] template<typename B> int f(X<B>, X<myint>); ^ Dodji, as the diagnostics maintainer, would that be an acceptable fix?