title: Control reaches end of non-void function
body: <p>The following code snippet generates some warning messages when compiling:</p>
  
  <pre><code>Cluster&amp; Myclass::getCluster(const Point &amp;p)
  {
      foreach (Cluster c, *this)
          foreach (Point point, c)
              if (point == p)
                  return c;
  }
  </code></pre>
  
  <p>The warnings are:</p>
  
  <ol>
  <li>reference to local variable 'c' returned [enabled by default]</li>
  <li>control reaches end of non-void function [when using <code>-Wreturn-type</code>]</li>
  </ol>
  
  <p>I know that I am not returning a value if the condition fails. However, when I try <code>return 0</code> it gave me error.</p>
  
  <p>How can I solve these issues?</p>