title: GCC warning [Wuninitialized]
body: <p>Why GCC 4.7 complains when instantiate a class inside a function (with a pointer)?</p>
  
  <p>Bad:</p>
  
  <pre><code>#include "foo.h"
  
  int fn () {
      Foo *foo;
      foo-&gt;method();
  
     return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>main.cpp: In member function 'int foo()':
    main.cpp:21:52: warning: 'fn' may be used uninitialized in this
    function [-Wuninitialized]</p>
  </blockquote>
  
  <p>Good:</p>
  
  <pre><code>#include "foo.h"
  
  Foo *foo;
  
  int fn () {
      foo-&gt;method();
  
     return 0;
  }
  </code></pre>
  
  <p>Good:</p>
  
  <pre><code>#include "foo.h"
  
  int fn () {
      Foo foo;
      foo.method();
  
     return 0;
  }
  </code></pre>