title: Initialisation of static variable with itself
body: <p>Consider following code example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  static int bar = bar;
  
  int main()
  {
      int foo = foo;
      std::cout &lt;&lt; "foo = " &lt;&lt; foo &lt;&lt; std::endl;
      std::cout &lt;&lt; "bar = " &lt;&lt; bar &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I get following compiler warning:</p>
  
  <pre><code>main.cpp: In function 'int main()':
  main.cpp:7:15: warning: 'foo' is used uninitialized in this function [-Wuninitialized]
       int foo = foo;
                 ^
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>foo = 0
  bar = 0
  </code></pre>
  
  <p>I expected this warning as foo is used unitialised. Instead of 0, 'foo' can be anything. 
  Self-assignment is undefined.</p>
  
  <p>But why is the the self-assignment of 'bar' not warned? Is this assignment of 'bar' defined or undefined behaviour and why?</p>
  
  <p>I know, static variables of elementar data types are initialised with '0' but in this case, the variable 'bar' is used during its initialisation. I'm wondering, if this is defined behaviour and the '0' is the expected output. (Which would explain, that no compiler warning occurs).</p>
  
  <p><a href="http://coliru.stacked-crooked.com/a/925cc0d0f3d9e5b1">Link to Live example</a></p>