[edit] Duplication and constants

Two issues:

  • The table on this page is confusing: rows 1 and 2 are identical, as are 3 and 4. Is there anything on this page that makes some distinction between e.g. 1 and 2?
  • Saying that you can only allocate arrays of compile-time constant integer length probably isn't right; maybe what was meant was that for expressions like new int[n][42], all but the first index must be constant?
--Nate 13:22, 22 June 2012 (PDT)
1) There were parentheses missing in (2) and (4) versions.
2) Yes. I've removed that statement for now.
-- P12 05:34, 23 June 2012 (PDT) 08:29, 27 October 2012 (PDT) "If array_n is present, an array of array_n objects is initialized, passing init_params as parameters to the constructor of each object or invoking default constructor if init_params are not present."

like int* int_array = new int[12](1); ? this is not allowed.

Indeed. The standard is quite unclear though - it doesn't say that initialization of an array in such a way is forbidden. The syntax definition apparently allows it. P12 11:47, 27 October 2012 (PDT)
Is there any compiler supporting it? 13:23, 4 November 2012 (PST)
int* int_array = new int[12](1); is ill-formed, no compiler should support it. The allowed syntax for array initialization in a new-expression would be the old int* int_array = new int[12](); and the new int* int_array = new int[12]{1};, int* int_array = new int[12]{1,2,3};, etc, supported by clang and gcc for example. See §5.3.4[]/15 which sends off to §8.5[dcl.init]/16, which says, for this particular case, "if the destination type is an array, the program is ill-formed" --Cubbi 22:14, 4 November 2012 (PST)