<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 19, 2013 at 10:43 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Jun 19, 2013, at 9:15 AM, Larisse Voufo <<a href="mailto:lvoufo@google.com">lvoufo@google.com</a>> wrote:<br>
> Just out of curiosity, I have noticed that Clang currently allows the following program:<br>
><br>
> template<typename T> T f() { return 13; }<br>
> template int f() { return 1; }<br>
><br>
> It essentially parses the body of the explicit instantiation only to ignore it.<br>
> Was this a conscious decision?<br></div></blockquote><div><br></div><div>I just spoke to Richard Smith about this, and it appears that the current behavior is a bit different from the way I just described it above. </div>
<div>The declaration for the template instantiation is parsed, but the 'template' keyword is ignored, which leads to two different behaviors for the calls f() and f<int>().</div><div>While f() returns 1, f<int>() returns 13. f() picks up the declaration "<span style="color:rgb(80,0,80)">int f() { return 1; }" while f<int>() picks up the template declaration and implicitly instantiates it.</span></div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
<br>
</div>No; please file a bug. You cannot define a function in an explicit instantiation.<br></blockquote><div><br></div><div style>I can quickly fix this or submit a patch. Should I still file a bug? </div><div style> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br>
> GCC 4.6.3 rejects the program with "expected ‘;’ before ‘{’ token".<br>
<br>
</div>Well, hopefully we can do better than that. <br></blockquote><div> </div><div style>What do you have in mind? </div><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
John.</font></span></blockquote></div><br></div></div>