Aggregates initialization
Are the extra elements always initialized, when the number of initializers is less than the number of aggregate's elements?If brace-enclosed initializer, ISO/IEC14882:2003 $8.5.1 specifies the extra elements are value-initialized as aggregates initialization, and ISO/IEC9899:1999 specifies, too.
Otherwise, if the initialization of character arrays by string literal, ISO/IEC14882:2003 does not specify this initialization against the extra elements. $8.5.1 does not apply with the string-literal initialization by &8.5.1.
On the other hand, ISO/IEC9899:1999 specifies the initialization is same as the way of static duration storage, which means zero-initialization.
I do not know why C++ does not specify the initialization of the extra elements.
C++ may say that character arrays initialized by string-literal should be used as only strings. If a programmer want to use an array as non-string storage, the programmer should initialize the array with brace.
No comments:
Post a Comment