This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: VLA parameters
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: shiv <00shiv at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Sun, 28 Jun 2015 20:48:21 +0100
- Subject: Re: VLA parameters
- Authentication-results: sourceware.org; auth=none
- References: <1435519289905-1163574 dot post at n5 dot nabble dot com>
On 28 June 2015 at 20:21, shiv <00shiv@gmail.com> wrote:
> Reading the gcc 5.1 manual it seems that VLA parameters must be accepted by
> g++. For example the following is fine when compiled with gcc --std=gnu11
>
> ///////////////////////////////////
> float sum (int M, float x[M]) {
> return x[0] + x[1];
> }
>
> int main (void) {
> float xs[2] = {1, 2};
> float acc = sum (2, xs);
> return 0;
> }
> /////////////////////////////////
>
> But it is rejected by g++ --std=gnu++11.
>
> Is this possible at all with g++? Thanks.
No, I don't think so, G++ only supports some kinds of VLA.
You have to use float x[] or float* x in C++.