Why is this valid C

The excess elements are just ignored. There are two parts of 6.7.8 Initialization that you care about. First, from paragraph 17:

Each brace-enclosed initializer list has an associated current object. When no designations are present, subobjects of the current object are initialized in order according to the type of the current object: array elements in increasing subscript order, structure members in declaration order, and the first named member of a union.

That one explains why you get 1, 7, and 9 – the current object gets set by those braces. Then as to why it doesn’t care about the extras, from paragraph 20:

… only enough initializers from the list are taken to account for the elements or members of the subaggregate or the first member of the contained union; any remaining initializers are left to initialize the next element or member of the aggregate of which the current subaggregate or contained union is a part.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)