This looks like a bug in the older version of clang
since version 3.5
gives me the following warning for this code:
warning: initializer for aggregate is not a compile-time constant [-Wc99-extensions]
int bar[1] = { foo };
^~~~~~~
and an error with your compile options (see it live).
Lacking a public C89 draft, I found gcc
has a section on Non-Constant Initializers which says:
As in standard C++ and ISO C99, the elements of an aggregate initializer for an automatic variable are not required to be constant expressions in GNU C.
which confirms that they used to be required to be constant expressions pre C99.
As tab informs us, the relevant quote from the C89 standard is from sectioon 3.5.7
and says:
All the expressions in an initializer for an object that has static storage duration or in an initializer list for an object that has aggregate or union type shall be constant expressions.