title: Variable templates and std::cout -- order of construction
body: <p>It looks like we can safely use <code>std::cout</code> object in constructors of objects with static storage duration as stated in this <a href="https://stackoverflow.com/questions/8784892/is-stdcout-guaranteed-to-be-initialized">question</a>.</p>
  
  <p>However, I'm not entirely sure that we can safely use them in case of variable templates:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template&lt;class T&gt;
  T x = T{};
  
  void foo()
  {
      class Test
      {
      public:
          Test() { std::cout &lt;&lt; "Test::Test\n"; }
      };
  
      Test t = x&lt;Test&gt;;
  }
  
  
  int main()
  {
      std::cout &lt;&lt; "main\n";
  }
  </code></pre>
  
  <p>This code crashes in clang (<a href="http://coliru.stacked-crooked.com/a/c20353f4224bfb7b" rel="nofollow noreferrer">live example</a>) and I'm not sure whether it's a bug or not.</p>