------- Comment #6 from Zarathustra at gentlemansclub dot de  2007-03-09 12:35 
-------
(In reply to comment #5)
> So, the way I read this is that gcc3.3 and icc9.0 agree that the call is
> ambiguous. I must admit that I don't know whether this is the correct
> behavior.
Also the SunCC yields the ambiguity message. I think in all such cases the
compilers do not implement all rules for the look up of template names as given
by the standard. Probably starting from version 3.4.0 of gcc the error message
changes.

Perhaps it is worth taking a look at the following code:
One template argument is left away, and some "<>" are added.
foo2 is accepted, foo3 is not! From this I assume that there is some problem
with the implementation of the argument-dependent lookup (ADP) in gcc. Does
anyone have any other assumptions?

struct cons_end {};

template<typename U,typename V> struct cons {
 U elem;
 V tail;
};

template<typename U, typename V>
void foo2(U elem, V tail)
{
 foo2(tail.elem,tail.tail);
}

template<typename U>
void foo2(U elem, cons_end tail)
{}

template<typename U, typename V>
void foo3(U elem, V tail)
{
 foo3<>(tail.elem,tail.tail); // <-- the difference is here (<> added)
}

template<typename U>
void foo3(U elem, cons_end tail)
{}

int main()
{
 cons<int,cons<int,cons_end> > list;
 foo2(list.elem,list.tail);
 foo2<>(list.elem,list.tail);
 foo3(list.elem,list.tail);
}

The error message (from gcc 4.1.2 and gcc 4.3):
test_gccbug.cpp: In function "void foo3(U, V) [with U = int, V = cons_end]":
test_gccbug.cpp:32:   instantiated from "void foo3(U, V) [with U = int, V =
cons<int, cons_end>]"
test_gccbug.cpp:44:   instantiated from here
test_gccbug.cpp:32: error: "struct cons_end" has no member named "elem"
test_gccbug.cpp:32: error: "struct cons_end" has no member named "tail"

Volker


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30822

Reply via email to