title: Can C++ constexpr function actually accept non-constant expression as argument?
body: <p>I have defined a constexpr function as following:</p>
  
  <pre><code>constexpr int foo(int i)
  {
      return i*2;
  }
  </code></pre>
  
  <p>And this is what in the main function:</p>
  
  <pre><code>int main()
  {
      int i = 2;
      cout &lt;&lt; foo(i) &lt;&lt; endl;
      int arr[foo(i)];
      for (int j = 0; j &lt; foo(i); j++)
          arr[j] = j;
      for (int j = 0; j &lt; foo(i); j++)
          cout &lt;&lt; arr[j] &lt;&lt; " ";
      cout &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>The program was compiled under OS X 10.8 with command clang++. I was surprised that the compiler did not produce any error message about foo(i) not being a constant expression, and the compiled program actually worked fine. Why?</p>