title: Why in C a const object is not a compile-time constant expression?
body: <p>In C the <code>const</code> qualifier makes an object read-only but not a constant expression. For example, it is not possible to use a <code>const int</code> variable to dimension an array:</p>
  
  <pre><code>const int n = 10;
  int arr [n];         /* Compile-time error */
  </code></pre>
  
  <p>Which is the technical reason for this? Is it not possible for the compiler at compile-time to know that the object has actually a constant value?</p>
  
  <hr>
  
  <p>I don't think that my question is an <strong>exact</strong> duplicate of <a href="https://stackoverflow.com/q/18848537/1920473">Can a const variable be used to declare the size of an array in C?</a>
  because I'm not asking if that's possible (it is clearly stated in my question that it is not) but <strong>the technical reason why</strong> it's not possible.</p>
  
  <hr>
  
  <p>After the comment of Olaf below, <a href="https://stackoverflow.com/a/18851139/1920473">this answer</a> and some musings I would try to summarize and answer my question in this way:</p>
  
  <p>In C a <code>const</code> object is not a <strong><em>compile-time constant</em></strong> because it can violate both requirements:</p>
  
  <p>First, it is possible to initialize the <code>const</code> object at runtime as in:</p>
  
  <pre><code>int i;
  scanf ("%d", &amp; i);
  const int n = i;
  </code></pre>
  
  <p>so here we violate the requirement of "known at compile-time".</p>
  
  <p>Secondly, as Olaf pointed out, the <code>const</code> qualifier means that the <strong>program itself</strong> will not modify the value of the object after the declaration-initialization. But the value of the object in memory could still be modified by some other entity outside the program itself, so here we are not guaranteeing the requirement of actual constness.</p>
  
  <p>Please criticize if this answer is incorrect or incomplete.</p>