<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 28, 2015 at 12:14 PM, Michael Park <span dir="ltr"><<a href="mailto:mcypark@gmail.com" target="_blank">mcypark@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Thanks for bringing this up Richard!</div><span class=""><div><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"><div dir="ltr"><div class="gmail_extra"></div><div class="gmail_extra">we reject the corresponding non-template case</div></div></blockquote><div><br></div></span><div>It looks like we <b>correctly</b> reject the non-template case.</div></div></div></div></blockquote><div><br></div><div>Right.</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 class="gmail_extra"><div class="gmail_quote"><div>The GCC folks ran into that case and declared it invalid: <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51080" target="_blank">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51080</a>.</div><span class=""><div><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"><div dir="ltr"><div class="gmail_extra">but accept the corresponding non-local class template case.</div></div></blockquote><div><br></div></span><div>In terms of standardese, I haven't dug deep enough to determine whether this case is valid or not. Perhaps you know the answer to this already?</div></div></div></div></blockquote><div><br></div><div>The answer is that we don't really know. It would be more consistent with the non-template case for it to be ill-formed (it also seems reasonable to say that you can't instantiate a member function until its class is complete), but the point of instantiation rules for constexpr functions aren't settled yet; this is part of DR1581 (still open).</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>In terms of our implementation, given that the non-template case is ill-formed:</div><span class=""><div><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">struct X {<br>    static constexpr int get() { return 42; } </blockquote></span><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">    int arr[get()];  // ill-formed: get() not defined here.<br>};  // get() is defined here.</blockquote><div><br></div><div>It makes sense to me that the following would not work either:</div><span class=""><div><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">void f() { </blockquote><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">  struct X {<br>    static constexpr int get() { return 42; }<br>    int arr[get()];<br>  }<br>}</blockquote><div><br></div></span><div>Given that the class template case works (again, not sure about the standardese):</div><div> <br></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">template <typename></blockquote><span class=""><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">struct X { </blockquote><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">    static constexpr int get() { return 42; } </blockquote><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">    int arr[get()]; </blockquote><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">}; </blockquote><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"> </blockquote></span><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">template class X<void>;</blockquote></div><div><br></div><div>I think the following should work also:</div><div><br></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">template <typename></blockquote><span class=""><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">void f() {</blockquote><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">  struct X {<br>    static constexpr int get() { return 42; }<br>    int arr[get()];<br>  }<br>}</blockquote><div> </div></span></div><div><div>I think we need to distinguish the 2 cases (1) a local class enclosed in a non-template function and (2) a local class enclosed in a function template. A local class within a non-template function would behave similarly to a non-template class whereas a local class within a function template would behave similarly to a class template. Currently we seem to treat a local class similar to a non-template class whether it's enclosed in a non-template function or a function template.</div></div></div></div></div>
</blockquote></div><br></div></div>