title: C and C++ functions without a return statement
body: <p>While looking through code at work I found some (seemingly) offensive code in which a function had a return type, but no return. I knew the code worked, but assumed it was just a bug in the compiler.</p>
  
  <p>I wrote the following test and ran it using my compiler <strong>(gcc (Homebrew gcc 5.2.0) 5.2.0)</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int f(int a, int b) {
    int c = a + b;
  }
  
  int main() {
     int x = 5, y = 6;
  
     printf("f(%d,%d) is %d\n", x, y, f(x,y)); // f(5,6) is 11
  
     return 0;
  }
  </code></pre>
  
  <p>Analogous to the code I found at work, this defaults to returning the result of the last expression executed in the function.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/10858391/why-do-programs-in-c-compile-even-when-the-return-statement-is-missing">this</a> question, but was not satisfied with the answer. I know that with <code>-Wall -Werror</code> this behavior can be avoided, but why is it an option? Why is this <em>still</em> allowed?</p>