Language-lawyer-wise, which clause in the standard forbid below code:
int arr[] (10, 42);
This would produce an array of 10 elements, each initalized to 42.
Language-lawyer-wise, which clause in the standard forbid below code:
int arr[] (10, 42);
This would produce an array of 10 elements, each initalized to 42.
Language-lawyer wise, 8.5/17:
— If the initializer is a (non-parenthesized) braced-init-list, the object or reference is list-initialized (8.5.4).
— If the destination type is a reference type, see 8.5.3.
— If the destination type is an array of characters, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string literal, see 8.5.2.
— If the initializer is (), the object is value-initialized.
— Otherwise, if the destination type is an array, the program is ill-formed
A braced-init-list is { } where anything (or nothing) can be inside the brackets (for example, int arr[3] = {1,2,3}
). With that in mind, none of the first 4 options are viable for int arr[] (10, 42);
, leaving the last one indicating the program is ill-formed.
8.5/14:
If the entity being initialized does not have class type, the expression-list in a parenthesized initializer shall be a single expression.