title: Initializing C++ array in constant time
body: <pre><code>char buffer[1000] = {0};
  </code></pre>
  
  <p>This initializes all 1000 elements to 0. Is this constant time? If not, why?</p>
  
  <p>It seems like the compiler could optimize this to O(1) based on the following facts:</p>
  
  <ol>
  <li>The array is of fixed size and known at compile time</li>
  <li>The array is located on the stack, which means that presumably the executable could contain this data in the data segment of the executable (on Windows) as a chunk of data that is already filled with 0's.</li>
  </ol>
  
  <p>Note that answers can be general to any compiler, but I'm specifically interested in answers tested on the MSVC compiler (any version) on Windows.</p>
  
  <p>Bonus Points: Links to any articles, white papers, etc. on the details of this would be greatly appreciated.</p>