<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 26, 2016 at 3:58 PM, Duncan P. N. Exon Smith via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On 2016-May-25, at 16:41, Hal Finkel via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
><br>
> From: "James Dennett via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
> To: "Akira Hatanaka" <<a href="mailto:ahatanak@gmail.com">ahatanak@gmail.com</a>><br>
> Cc: "Richard Smith" <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>>, "Clang Dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
> Sent: Wednesday, May 25, 2016 6:37:46 PM<br>
> Subject: Re: [cfe-dev] c++ question: can lambda be used in VLA?<br>
><br>
> On Wed, May 25, 2016 at 4:19 PM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com">ahatanak@gmail.com</a>> wrote:<br>
> On Tue, May 24, 2016 at 7:11 PM, James Dennett <<a href="mailto:james.dennett@gmail.com">james.dennett@gmail.com</a>> wrote:<br>
> On Tue, May 24, 2016 at 6:25 PM, Akira Hatanaka via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
> I wasn't requesting that clang accept lambda expressions used for array bounds but was asking whether it was valid in c++. Is this something that is open to interpretation because it's not covered by the standard?<br>
><br>
> FYI, this isn't something that I made up. It was in a code a user wrote.<br>
><br>
><br>
> It's covered by the standard, and as Clang's error message says, lambdas are not allowed in constant expressions in C++11 or C++14.<br>
><br>
><br>
> Yes, the c++ standard gives a list of subexpressions that are not allowed in constant expressions and lambda expression is one of them.<br>
><br>
> This doesn't seem to apply to C99's extension for variable length arrays because array sizes are not required to be constant expressions.<br>
><br>
><br>
> I was replying to you saying that you were "asking whether it was valid in C++", and whether "it's not covered by the standard".<br>
><br>
> C99 doesn't have lambdas, so it doesn't allow this. C++ doesn't have VLAs, so it doesn't allow it.<br>
><br>
> The de facto language accepted by Clang doesn't accept it, as you already noted.<br>
><br>
> There's no specification that tells us what the "right thing to do" is here. We could extend Clang to support this non-standard combination of C99 with C++11, and it might even make it a little more consistent, but if it adds any implementation complexity then it may not be worthwhile to support a corner case that's not allowed by any language standard.<br>
> What did the most recent wording for C++ ARBs say about this issue?<br>
<br>
</span>The latest version I could find is here:<br>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html#Introduction" rel="noreferrer" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html#Introduction</a><br>
<br>
The changes to 8.3.4 Arrays [dcl.array] change the argument from a constant-expression_opt to an expression_opt:<br>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html#dcl.array" rel="noreferrer" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html#dcl.array</a><br>
<br>
I think the Array TS was killed in Jacksonville due to lack of interest, but the interaction between these features seems straightforward to me. When the C++ language extension for VLAs is turned on, we shouldn't treat the array argument as a constant-expression.</blockquote><div><br></div><div>This isn't quite that simple... We do not have a C++ language extension for VLAs that can be turned on and off in the way you seem to expect. What we have is an extension warning that can be disabled or turned into an error. Following our usual philosophy for warning flags, it's not reasonable for -Wno-vla to affect how we parse an array bound.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> This effectively allows lambdas in array bounds.<br>
<br>
Akira, what does the patch for this look like?<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> -Hal<br>
><br>
> -- James<br>
><br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
><br>
><br>
><br>
> --<br>
> Hal Finkel<br>
> Assistant Computational Scientist<br>
> Leadership Computing Facility<br>
> Argonne National Laboratory<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>