Variable Length Array (VLA) in C++ compilers
<p>As we already know, <a href="https://en.wikipedia.org/wiki/Variable-length_array" rel="noreferrer">VLA</a> (standardized in <em>C99</em>) are not part of the standard in C++.</p>

<p>So the code below is <em>"illegal"</em> in <em>C++</em>:</p>

<pre><code>void foo(int n) {
  int vla[n];
  for (int i = 0; i &lt; n; ++i) {
    vla[i] = i;
  }
}
</code></pre>

<p>Despite of that the compiler (<em>g++</em> and <em>clang++</em>) <em>accepts</em> the code as valid syntax, producing just a <em>warning</em> <em>in case <code>-pedantic</code> flag is enable</em>.</p>

<blockquote>
  <p>ISO C++ forbids variable length array ‘vla’ [-Wvla]</p>
</blockquote>

<p>My questions are:</p>

<ul>
<li><p>Why does the compiler accept that declaration? <br>
The compiler cannot just reject an array in which length <code>[is-no-know-at-compile-time]</code>? <br>
Is there a sort of compatibility syntax rule to follow?</p></li>
<li><p>What does the standard say about? <br>
From the assembly code produced I see the compiler writes in the stack
in the loop, like a normal array, but I cannot find anything about the standard behaviour.</p></li>
</ul>