How is this happening with static?
<p>Need help to understand the following behaviour.</p>

<pre><code>static int a;
int b[a];

for(int i=0; i&lt;10; i++)
    b[i] = i+1;

for(int i=0; i&lt;10; i++)
    cout &lt;&lt; " " &lt;&lt; b[i];
</code></pre>

<p>The output is 
$> 1 2 3 4 5 6 7 8 8 10</p>

<p>However if I declare variable 'a' as auto [like int a] then it crashes at run-time, which is obvious. But why is it working with static.
Also if I run the loop for more number of time(above it is 10) it crashes. I made it 12 and it crashed. Moreover in the output 8 is coming instead of 9 in between 8 &amp; 10 which is abnormal. Please help.....</p>
