Initializing Automatic Arrays and Structures

When the GCC extensions setting is on, array and structure variables that are local to a function and have the automatic storage class may be initialized with values that do not need to be constant. Initializing arrays and structures with non-constant values shows an example.

Listing 1. Initializing arrays and structures with non-constant values
void f(int i)
{
    int j = i * 10; /* Always OK. */

    /* These initializations are only accepted when GCC extensions
     * are on. */
    struct { int x, y; } s = { i + 1, i + 2 }; 
    int a[2] = { i, i + 2 };

}