1

Topic: value-initialization Dynamic array

A* a = new A [10 (5);

GCC 5.4 it is possible to force to gobble up such syntax a key-fpermissive, thus at all
Ten objects designers will really be caused and all will work as is expected.
This extension is pure at GCC or in any edition of the standard a subject already resolved?

2

Re: value-initialization Dynamic array

No, this non-standard.
According to the standard, after new A [10] there can be only an array initialiser.
I.e. A [10] {<10 values>} if at A there is no default constructor, or A [10] {<no more than 10 values>} if are a default constructor.

3

Re: value-initialization Dynamic array

Anatoly Moskovsky wrote:

Is not present, this non-standard.

It is a pity, a convenient piece. As the standard resolves such construction:

A a [10 (5);

4

Re: value-initialization Dynamic array

Dimitry Sibiryakov wrote:

It is a pity, a convenient piece. As the standard resolves such construction:

A a [10 (5);

This too does not resolve.

5

Re: value-initialization Dynamic array

Anatoly Moskovsky wrote:

This too does not resolve.

However, resolves:

cppreference wrote:

3) if T is an array type, each element of the array is
value-initialized;

6

Re: value-initialization Dynamic array

7

Re: value-initialization Dynamic array

Dimitry Sibiryakov;
Since GCC 7 too ceases to compile

8

Re: value-initialization Dynamic array

However here there is such feature that is simple ...
At first it should be applied aggregate initialization (point the following 11.6.1 drafts), but it works originally

#include <iostream>
using namespace std;
struct A {
int m_a, m_b;
//A (int x, int y) {m_a = x; m_b = y;}//it is mandatory  the designer
};
int main ()
{
A var_a [10] = {{5,1}};
int z [3] = {-1};
cout <<z [0] <<z [2] <<endl;
cout <<var_a [0].m_a <<var_a [0].m_b <<endl;
cout <<var_a [9].m_a <<var_a [9].m_b <<endl;
}

Output [quote =]-10
51
00