<div dir="ltr"><br><div>Hi all,</div><div><br></div><div>This is with respect to the following test case:</div><div><br></div><div><div>struct A {</div><div>    struct B { typedef int X; };</div><div>};</div><div><br></div>
<div>template<class B> struct C : A {</div><div>    B::X q; // Ok: A::B.</div><div>    struct U { typedef int X; };</div><div>    template<class U></div><div>        struct D;</div><div>};</div><div><br></div>
<div>template<class B></div><div>template<class U></div><div>struct C<B>::D {</div><div>    typename U::X r; // { dg-error "" }</div><div>};</div><div><br></div><div>C<int>::D<double> y;</div>
<div><br></div></div><div>As far as I am able to make out, this code compiles fine with Clang, because the statement   typename U::X r; resolves for U by looking up the class members first and than the template parameter list.</div>
<div> </div><div>But isnt it supposed to throw an error based on the following wordings from the standard (The wordings in the bracket are of interest to us):</div><div><br></div><div><div>In the definition of a member of a class template that appears outside of the class template definition, the name of a member of the class template hides the name of a template-parameter of any enclosing class templates (but not a template-parameter of the member if the member is a class or function template).</div>
<div><br></div><div><br></div><div>Note: The below mentioned example is from the standards.</div><div><br></div><div>Example:</div><div><br></div><div>template<class T> struct A {</div><div>struct B { /* ... */ };</div>
<div>typedef void C;</div><div>void f();</div><div>template<class U> void g(U);</div><div>};</div><div><br></div><div>template<class B> void A<B>::f() {</div><div>B b;   // A’s B, not the template parameter</div>
<div>}</div><div><br></div><div>template<class B> template<class C> void A<B>::g(C) {</div><div>B b; // A’s B, not the template parameter</div><div>C c; // the template parameter C, not A’s C , this is the case I suppose we           are not handling</div>
<div>}</div></div><div><br></div><div><br></div><div>Am I missing something in my analysis or is this a potential bug??</div><div><br></div><div>Inputs on this would be really helpful.</div><div><br></div><div>Thanks,</div>
<div>Rahul</div><div><br></div><div><br></div><div><br></div></div>