Returning a pointer in a good way
<p>Is this code is completely valid? Will returning a pointer here will not throw us to undefined behavior?</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int* lab(int* i) {
        int k=9;
        i=&amp;k;
        return i;
}

int main(void) {
        int* i=0;
        cout &lt;&lt; *lab(i) &lt;&lt; endl;
        return 0;
}
</code></pre>

<p><strong>EDIT</strong>: how valid code can look like?</p>
