title: Array size at run time without dynamic allocation is allowed?
body: <p>I've been using C++ for a few years, and today I saw some code, but how can this be perfectly legal?</p>
  
  <pre><code>int main(int argc, char **argv)
  {
      size_t size;
      cin &gt;&gt; size;
      int array[size];
      for(size_t i = 0; i &lt; size; i++)
      {
          array[i] = i;
          cout &lt;&lt; i &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p><sup>Compiled under GCC.</sup></p>
  
  <p>How can the size be determined at run-time without <code>new</code> or <code>malloc</code>?</p>
  
  <p>Just to double check, I've googled some and all similar codes to mine are claimed to give storage size error.</p>
  
  <p>Even Deitel's C++ How To Program p. 261 states under Common Programming Error 4.5: </p>
  
  <blockquote>
    <p>Only constants can be used to declare the size of automatic and static arrays.</p>
  </blockquote>
  
  <p>Enlight me.</p>