This statement
int array[a]={0};
declares a Variable Length Array (VLA).
According to C Standard (6.7.9 Initialization)
3 The type of the entity to be initialized shall be an array of
unknown size or a complete object type that is not a variable length
array type.
The problem is that the compiler shall know the array size at compile time that to generate the code that initialize an array.
Consider an example
void f( size_t n )
{
int a[n] = { 1, 2, 3, 4, 5 };
//...
}
Here is a is a variable length array. Now as n can have any value then the number of initializers in the array definition can be greater than the size of the array. So this code breaks the Standard from another side because the number of initializers may not be greater than the number of elements of array. On the other hand if the number of initializers less than the number of elements of array then what to do in this case? Maybe the programmer did not mean that some elements shall be zero-initialized.
As for this declaration
int array[5]={0};
then there is no variable length array. The size of the array is known at compile time. So there is no problem
.