WU Yongwei wrote:

> Well, I see this in the gcc error message.  Can someone here kindly
> point to me which part of the Standard specified this behaviour?  I
> thought it should be in 5.3.4, but was not able to find the words
> there.

It might be better if the error message said "non-default
initialization" since default initialization is allowed (and required).

I assume you are trying something like this:

    int* i = new int[5](23);


A new initializer must have the form (...) (see 5.3.4/1) and the only
way that can be used to initialize an array is for default construction.


This is OK, and default initialises the array, which default initialises
each element (8.5/5)

    int* i = new int[5]();

but this is not OK:

    int* i = new int[5](23);

because it is not valid to initialise an array like this:

    typedef int (five_ints)[5];
    five_ints i(23);

this gives:

array_init.cc:8: error: cannot initialize arrays using this syntax

HTH

jon

-- 
sigfault

Reply via email to