title: How to get around GCC ‘*((void*)& b +4)’ may be used uninitialized in this function warning while using boost::optional
body: <p>I have code similar to the following:</p>
  
  <pre><code>#include &lt;boost/optional.hpp&gt;
  
  ::boost::optional&lt;int&gt; getitem();
  
  int go(int nr)
  {
    boost::optional&lt;int&gt; a = getitem();
    boost::optional&lt;int&gt; b;
  
    if (nr &gt; 0)
      b = nr;
  
    if (a != b)
      return 1;
  
    return 0;
  }
  </code></pre>
  
  <p>When compiling with GCC 4.7.2 with Boost 1.53, using the following command:</p>
  
  <blockquote>
    <p>g++ -c -O2 -Wall -DNDEBUG</p>
  </blockquote>
  
  <p>The following warning is issued:</p>
  
  <blockquote>
    <p>13:3: warning: ‘<em>((void</em>)&amp; b +4)’ may be used uninitialized in this function [-Wmaybe-uninitialized]</p>
  </blockquote>
  
  <p>Apparently, the root problem lies with GCC. See <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47679" rel="noreferrer">GCC Bugzilla</a>
  Does anyone know a workaround?</p>