clang 3.0 and g++ 4.8.1 both reject the following code with the error shown in the comment:
template<typename T>
struct S
{
void f()
{
this->dependent(); // no error: type of 'this' is dependent?
this->Dependent::dependent(); // error: 'Dependent' has not been declared
}
};
According to [basic.lookup.classref]
the class-name-or-namespace-name following the . or -> operator is looked up both in the context of the entire postfix-expression and in the scope of the class of the object expression.
And [temp.dep.expr]
this
is type-dependent if the class type of the enclosing member function is dependent.
If the class-or-namespace-name Dependent
is looked up 'in the scope of the class of the object expression* this
, and the class of the object expression is dependent, should this lookup not be deferred until the template is instantiated? Does the standard specify the correct behaviour?
EDIT: clang 3.0 accepts the following code, but g++4.8 gives the same error as above
template<typename T>
struct S
{
T m;
void f()
{
m.dependent();
m.Dependent::dependent();
}
};