http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53251
Bug #: 53251 Summary: template keyword ignored between -> and member under name collision with non-member Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: pot...@mac.com Minimal testcase: template< typename > class set; template< typename > struct b { template<typename T> void set(); }; template<typename T> struct d : b<T> { d() { this->template set<int>(); } }; int main() { d<int> s; } Diagnostic: In constructor ‘d<T>::d()’: 12:17: error: invalid use of ‘class set<int>’ The name "set" is looked up in the context of the expression, outside the class, perhaps per §3.4.5/1 [basic.lookup.classref]. Furthermore, a class found by lookup in expression scope per 3.4.5/1 must agree with lookup in class scope anyway (i.e. it must be a base class if class scope lookup succeeds) or the program is ill-formed. 3.4.5/1 does not apply because the template keyword is used to mark a dependent object expression. I suspect that somehow the hint carried by the keyword isn't properly restricting name lookup. For deeper discussion see http://stackoverflow.com/questions/10426428 .