title: C Storage Size Isn't a Constant...why?
body: <p>Here's the simple example program    </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  const char *hello_string = "Hello";
  
  int main(void)
  {
  char *world_string = " World";
  static char hello_world[strlen(hello_string)+strlen(world_string)];
  strcpy(&amp;hello_world[0], hello_string);
  strcat(&amp;hello_world[0], world_string);
  printf("%s\n", hello_world);
  return 0;
  }
  </code></pre>
  
  <p>The compiler output:</p>
  
  <pre><code>test.c: In function ‘main’:
  test.c:9:13: error: storage size of ‘hello_world’ isn’t constant
  static char hello_world[strlen(hello_string)+strlen(world_string)];
              ^
  </code></pre>
  
  <p>I realize the completely useless and unnecessary use of "static" in this case causes the error and with its removal things will compile fine. This is just a simple example to illustrate my question. </p>
  
  <p>What I don't understand is why the storage size is not a constant when the "hello_string" is declared as <strong>const</strong> char * and its size is not going to change during the course of execution. Is this just a case of the compiler not being smart enough to know that?</p>