<div dir="ltr">On Tue, Nov 26, 2013 at 10:26 AM, Rahul Jain <span dir="ltr"><<a href="mailto:1989.rahuljain@gmail.com" target="_blank">1989.rahuljain@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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></blockquote><div><br></div><div>Yes, this is a bug.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><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>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>