title: Why and how does GCC compile a function with a missing return statement?
body: <p>Consider:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  char toUpper(char);
  
  int main(void)
  {
      char ch, ch2;
      printf(&quot;lowercase input: &quot;);
      ch = getchar();
      ch2 = toUpper(ch);
      printf(&quot;%c ==&gt; %c\n&quot;, ch, ch2);
      
      return 0;
  }
  
  char toUpper(char c)
  {
      if(c&gt;='a' &amp;&amp; c&lt;='z')
          c = c - 32;
  }
  </code></pre>
  <p>In the <em>toUpper</em> function, the return type is <em>char</em>, but there isn't any &quot;return&quot; in <em>toUpper()</em>. And compile the source code with gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4), <a href="https://en.wikipedia.org/wiki/Fedora_Linux" rel="nofollow noreferrer">Fedora</a> 14.</p>
  <p>Of course, a warning is issued: &quot;warning: control reaches end of non-void function&quot;, but, working well.</p>
  <p>What has happened in that code during compile with gcc?</p>