Why does the one call on null succeeds and other fails? : <p>I am trying to run the following program : </p>

<pre><code>#include &lt;iostream&gt;
struct Foo {
    int x;
    void bar() {
        std::cout &lt;&lt; "La la la" &lt;&lt; std::endl;
    }
    void baz() {
        std::cout &lt;&lt; x &lt;&lt; std::endl;
    }
};
int main() {
    Foo *foo = NULL;
    foo-&gt;bar();
    foo-&gt;baz();
}
</code></pre>

<p><code>Output</code> : </p>

<pre><code>./a.out 
La la la
Segmentation fault (core dumped)
</code></pre>

<p>I am using g++ version 7.3.0 on ubuntu 18.04. Shouldn't both the calls fail as the object has been set to null?</p>
