Empty return in non-void function, is undefined behaviour?
<p>After reading answers about the topic of <em>control reaches end of non-void functions</em> I didn't see any answer adressing specifically the the case of exiting a non-void function with an empty <code>return</code> statement:</p>
<pre><code>int return_integer() { return; }  // empty return in non-void function
</code></pre>
<p>What I've found so far in the <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf" rel="noreferrer">C standard</a> is:</p>
<blockquote>
<h2>6.8.6.4 The return statement</h2>
<h3>Constraints</h3>
<ol>
<li>A <code>return</code> statement with an expression shall not appear in a function whose return type is <code>void</code>. A <code>return</code> statement without an expression shall only appear in a function whose return type is <code>void</code>.</li>
</ol>
</blockquote>
<p>The standard quote states what <strong>should</strong> we do with our <code>return</code> statements for <code>void</code> and non-<code>void</code> functions, what happens when we ignore the constraint is mentioned in other part of the document:</p>
<blockquote>
<h2>6.9.1 Function definitions</h2>
<ol start="12">
<li>If the <code>}</code> that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.</li>
</ol>
</blockquote>
<p>Previous standard quote states that UB happens if we use the returned value from a function which ends after reaching the closing curly braces (<code>}</code>), so we have UB in the code below:</p>
<pre><code>int UB(int x) { if (x) return x; }

printf(&quot;%d&quot;, UB(1)); // Correct
printf(&quot;%d&quot;, UB(0)); // Undefined behavior
</code></pre>
<p>In the <code>UB(1)</code> call the function returns <code>1</code> through the <code>return x;</code> instruction under the <code>if (x)</code>; in the <code>UB(0)</code> call the <code>if (x)</code> condition is not passed so function ends reaching <code>}</code>, to use the return value in this case is UB (but isn't in <code>UB(1)</code>). But, what happens in this case?</p>
<pre><code>int UB(int x) { if (x) return; } // empty return statement

printf(&quot;%d&quot;, UB(1)); // Undefined behavior?
printf(&quot;%d&quot;, UB(0)); // Undefined behavior
</code></pre>
<p>In the code above, the call <code>UB(1)</code> does not meet the <code>§6.9.1/12</code> requirements to lead to UB because the function ends <strong>without reaching <code>}</code></strong> and also does not return any value.</p>
<p>In which part of the C standard is this situation described?</p>