[cfe-dev] Is clang name lookup too restrictive for dependent base classes?

Enea Zaffanella zaffanella at cs.unipr.it
Wed Feb 10 14:51:58 PST 2010


Hello.

The following example is a simplified version of code occurring in 
doxygen-1.6.2 (in the qtools module):

=======================================
template <typename T>
struct List {
   void append(const T&) { }
};

template <typename T>
struct Stack : public List<T> {
   void push(const T& d) { append(d); }
};

struct Client {
   Stack<int> stack;
   void foo() { stack.push(0); }
};
=======================================


While g++ accepts it, clang complains as follows:

=======================================
# llvm/Debug/bin/clang++ -fsyntax-only test.cc
test.cc:8:27: error: use of undeclared identifier 'append'
   void push(const T& d) { append(d); }
                           ^
                           this->
test.cc:13:22: note: in instantiation of member function
       'Stack<int>::push' requested here
   void foo() { stack.push(0); }
                      ^
test.cc:3:8: note: must qualify identifier to find this declaration in
       dependent base class
   void append(const T&) { }
        ^
3 diagnostics generated.
=======================================

Since the call to append(d) is a type-dependent expression,
I would say that clang name lookup is too restrictive.
Or is it the case that g++ is too permissive?

Cheers,
Enea Zaffanella.



More information about the cfe-dev mailing list