[cfe-dev] c++ question: can lambda be used in VLA?
Hal Finkel via cfe-dev
cfe-dev at lists.llvm.org
Thu May 26 16:02:24 PDT 2016
----- Original Message -----
> From: "Duncan P. N. Exon Smith" <dexonsmith at apple.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "James Dennett" <james.dennett at gmail.com>, "Akira Hatanaka" <ahatanak at gmail.com>, "Richard Smith"
> <richard at metafoo.co.uk>, "Clang Dev" <cfe-dev at lists.llvm.org>
> Sent: Thursday, May 26, 2016 5:58:04 PM
> Subject: Re: [cfe-dev] c++ question: can lambda be used in VLA?
>
>
> > On 2016-May-25, at 16:41, Hal Finkel via cfe-dev
> > <cfe-dev at lists.llvm.org> wrote:
> >
> >
> > From: "James Dennett via cfe-dev" <cfe-dev at lists.llvm.org>
> > To: "Akira Hatanaka" <ahatanak at gmail.com>
> > Cc: "Richard Smith" <richard at metafoo.co.uk>, "Clang Dev"
> > <cfe-dev at lists.llvm.org>
> > Sent: Wednesday, May 25, 2016 6:37:46 PM
> > Subject: Re: [cfe-dev] c++ question: can lambda be used in VLA?
> >
> > On Wed, May 25, 2016 at 4:19 PM, Akira Hatanaka
> > <ahatanak at gmail.com> wrote:
> > On Tue, May 24, 2016 at 7:11 PM, James Dennett
> > <james.dennett at gmail.com> wrote:
> > On Tue, May 24, 2016 at 6:25 PM, Akira Hatanaka via cfe-dev
> > <cfe-dev at lists.llvm.org> wrote:
> > 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?
> >
> > FYI, this isn't something that I made up. It was in a code a user
> > wrote.
> >
> >
> > 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.
> >
> >
> > Yes, the c++ standard gives a list of subexpressions that are not
> > allowed in constant expressions and lambda expression is one of
> > them.
> >
> > This doesn't seem to apply to C99's extension for variable length
> > arrays because array sizes are not required to be constant
> > expressions.
> >
> >
> > 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".
> >
> > C99 doesn't have lambdas, so it doesn't allow this. C++ doesn't
> > have VLAs, so it doesn't allow it.
> >
> > The de facto language accepted by Clang doesn't accept it, as you
> > already noted.
> >
> > 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.
> > What did the most recent wording for C++ ARBs say about this issue?
>
> The latest version I could find is here:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html#Introduction
>
> The changes to 8.3.4 Arrays [dcl.array] change the argument from a
> constant-expression_opt to an expression_opt:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html#dcl.array
>
> I think the Array TS was killed in Jacksonville due to lack of
> interest,
Unfortunately; but not exactly for lack of interest. As far as I can tell, there was a lack of progress on the second more-C++-like companion part that was part of the compromise to get the ARBs.
-Hal
> 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. This effectively allows lambdas in array
> bounds.
>
> Akira, what does the patch for this look like?
>
> >
> > -Hal
> >
> > -- James
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >
> >
> >
> > --
> > Hal Finkel
> > Assistant Computational Scientist
> > Leadership Computing Facility
> > Argonne National Laboratory
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the cfe-dev
mailing list