Bug in g++ name resolution

Ian Searle ians@amc.com
Sun Sep 27 13:50:00 GMT 1998


We have encountered a bug in g++ name resolution.  I believe I have
provided all the necessary information as attachments.

In short, the following program should compile without error:

But, g++ does (even though there is no ambiguity):

egcs-bug-notwork.cc: In method `void C<T>::bar()':
egcs-bug-notwork.cc:17: request for member `foo' is ambiguous in multiple inheritance lattice

The program is:

#include <iostream>

template <class T>
struct A {
   void foo() { cout << "A::foo" << '\n' ;}
} ;

template <class T>
struct B : private A<T> {
protected:
   A::foo ;
} ;

template <class T>
struct C : private B<T> {
   void bar() { foo() ;}
} ;

int main()
{
    C<int> c ;
    c.bar() ;
    return 0 ;
}

Thanks,
-- 
Ian Searle
ians@amc.com
// ===================== THIS DOES NOT ======================
#include <iostream>

template <class T>
struct A {
   void foo() { cout << "A::foo" << '\n' ;}
} ;

template <class T>
struct B : private A<T> {
protected:
   A::foo ;
} ;

template <class T>
struct C : private B<T> {
   void bar() { foo() ;}
} ;

int main()
{
    C<int> c ;
    c.bar() ;
    return 0 ;
}


More information about the Gcc-bugs mailing list