This code:
template<typename T>
class   freeList {
public:
    T*      newNode() { return 0; }
    template<typename U>
    T*      newNode(U u) { return newNode()->init(u); }
    template<typename U, typename V>
    T*      newNode(U u, V v) { return newNode()->init(u, v); }
    };

class   bar {};
class   baz {};
class   foo : public freeList<bar>, public freeList<baz> { };

int main() {
    foo     f;
    bar*    b = f.newNode<bar>();
    }


gets you:
s3:~/ootbc/memspec$ g++ foo.cc
foo.cc: In function ‘int main()’:
foo.cc:17: error: request for member ‘newNode’ is ambiguous
foo.cc:8: error: candidates are: template<class U, class V> T*
freeList::newNode(U, V) [with U = U, V = V, T = baz]
foo.cc:6: error: candidates are: template<class U> T* freeList::newNode(U)
[with U = U, T = baz]
foo.cc:4: error: candidates are: T* freeList<T>::newNode() [with T = baz]
foo.cc:8: error:                 template<class U, class V> T*
freeList::newNode(U, V) [with U = U, V = V, T = bar]
foo.cc:6: error:                 template<class U> T* freeList::newNode(U)
[with U = U, T = bar]
foo.cc:4: error:                 T* freeList<T>::newNode() [with T = bar]
foo.cc:17: error: expected primary-expression before ‘>’ token
foo.cc:17: error: expected primary-expression before ‘)’ token


-- 
           Summary: confused compiler
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net


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

Reply via email to