...
but it is also possible to use designators to initialize array elements in a noncontiguous fashion. Section 6.7.9, Example 12, of the C standard [ISO/IEC 9899:2011] states:
Space can be "allocated" from both ends of an array by using a single designator:
Code Block int a[MAX] = { 1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0 };In the above, if
MAX
is greater than ten, there will be some zero-valued elements in the middle; if it is less than ten, some of the values provided by the first five initializers will be overridden by the second five.
...
CERT C++ Secure Coding Standard: ARR02-CPP. Explicitly specify array bounds, even if implicitly defined by an initializer
ISO/IEC 9899:2011 Section Section 6.7.9, "Initialization"
MITRE CWE: CWE-665, "Incorrect or incomplete initialization"
...