title: C++ variable-sized object may not be initialized
body: <p>I have the following simple source</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main() {
      int nv;
      nv = 3;
      int arr[nv] = { 0, 2, 5 };
      return 0;
  }
  </code></pre>
  
  <p>When compiling with GCC on system 1 I get </p>
  
  <pre class="lang-none prettyprint-override"><code>error: variable-sized object ‘arr’ may not be initialized.
  </code></pre>
  
  <p>When compiling with GCC on system 2 I get no errors.</p>
  
  <p>Compilation flags are the same in both cases, see below.</p>
  
  <p><strong>What is the reason for this, and how can I get my code to compile in system 1?</strong>
  I suspected it was related to gcc version, but I found no information to support this suspicion.</p>
  
  <p>In system 1:</p>
  
  <pre><code>$ g++ --version
  g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
  ...
  $ make
  g++ -MMD -g -g3 -Wall -Wunused -Wuninitialized -Wextra -fmessage-length=0 -std=gnu++11 -c -o obj/arrays_test.o src/arrays_test.cc
  ...
  </code></pre>
  
  <p>In system 2:</p>
  
  <pre><code>$ g++ --version
  g++ (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
  ...
  $ make
  g++ -MMD -g -g3 -Wall -Wunused -Wuninitialized -Wextra -fmessage-length=0 -std=gnu++11 -c -o obj/arrays_test.o src/arrays_test.cc
  ...
  </code></pre>