Can a (C/C++) array initialization reference itself? [duplicate]

See 3.3.2 Point of declaration:

The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its
initializer (if any), except as noted below. [ Example:

int x = 12;
{ int x = x; }

Here the second x is initialized with its own (indeterminate) value. —end example ]

So you are referring to the array correctly, its name is known after the =.

Then, 8.5.1 Aggregates:

An aggregate is an array or a class […]

17: The full-expressions in an initializer-clause are evaluated in the order in which they appear.

However, I see no reference to when the evaluated values are actually written into the array, so I wouldn’t rely on this and would even go so far to declare your code as not well defined.

Leave a Comment

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