Affected subclause: [dcl.init.aggr]
Change: In C++, designated initialization support is restricted
compared to the corresponding functionality in C
. In C++,
designators for non-static data members
must be specified in declaration order,
designators for array elements and nested designators
are not supported,
and
designated and non-designated initializers
cannot be mixed in the same initializer list
. Example:
struct A { int x, y; };
struct B { struct A a; };
struct A a = {.y = 1, .x = 2};
int arr[3] = {[1] = 5};
struct B b = {.a.x = 0};
struct A c = {.x = 1, 2};
Rationale: In C++, members are destroyed in reverse construction order
and the elements of an initializer list are evaluated in lexical order,
so field initializers must be specified in order
. Nested designators are seldom used
. Effect on original feature: Deletion of feature that is incompatible with C++
. Difficulty of converting: Syntactic transformation
. How widely used: Out-of-order initializers are common
. The other features are seldom used
.