title: Is std::cout guaranteed to be initialized?
body: <p>What I know about C++ is that the order of the constructions (and destructions) of global instances should not be assumed.</p>
  
  <p>While I'm writing code with a global instance which uses <code>std::cout</code> in the constructor &amp; destructor, I got a question.</p>
  
  <p><code>std::cout</code> is also a global instance of iostream. Is <code>std::cout</code> guaranteed to be initialized before any other global instances?</p>
  
  <p>I wrote a simple test code and it works perfectly, but still I don't know why.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct test
  {
      test() { std::cout &lt;&lt; "test::ctor" &lt;&lt; std::endl; }
      ~test() { std::cout &lt;&lt; "test::dtor" &lt;&lt; std::endl; }
  };
  
  test t;
  
  int main()
  {
      std::cout &lt;&lt; "Hello world" &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>It prints</p>
  
  <pre><code>test::ctor
  Hello world
  test::dtor
  </code></pre>
  
  <p>Is there any possibility that the code doesn't run as expected?</p>