title: Defining arrays with(out) constant expressions
body: <p>I am slowly bringing myself up to c++11. I was looking at <code>constexpr</code> and stumbled into this <a href="http://en.wikipedia.org/wiki/C++11#constexpr_.E2.80.93_Generalized_constant_expressions" rel="nofollow">wikipedia article</a> which lead me to "something completely different". The basic example it gives is:</p>
  
  <pre><code>int get_five() {return 5;}
  int some_value[get_five() + 7]; // Create an array of 12 integers. Ill-formed C++
  </code></pre>
  
  <p>It states "This was not legal in C++03, because get_five() + 7 is not a constant expression." and says that adding <code>constexpr</code> to the <code>get_five()</code> declaration solves the problem.</p>
  
  <p>My question is "What problem?". I compiled that code with neither errors nor warnings. I played with it making it horribly non constant:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int size(int x) { return x; }
  
  int main()
  {
    int v[size(5) + 5];
    std::cout &lt;&lt; sizeof(v) + 2 &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>This compiles with no complaints using:</p>
  
  <pre><code>g++ -Wall -std=c++03
  </code></pre>
  
  <p>and when executed I get the (correct) answer 42.</p>
  
  <p>I admit that I generally use stl containers, not arrays. But I thought (and apparently so did wikipedia) that compilation of the above code would fail miserably. Why did it succeed?</p>