title: When does invoking a member function on a null instance result in undefined behavior?
body: <p>Consider the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct foo
  {
      // (a):
      void bar() { std::cout &lt;&lt; "gman was here" &lt;&lt; std::endl; }
  
      // (b):
      void baz() { x = 5; }
  
      int x;
  };
  
  int main()
  {
      foo* f = 0;
  
      f-&gt;bar(); // (a)
      f-&gt;baz(); // (b)
  }
  </code></pre>
  
  <p>We expect <code>(b)</code> to crash, because there is no corresponding member <code>x</code> for the null pointer. In practice, <code>(a)</code> doesn't crash because the <code>this</code> pointer is never used.</p>
  
  <p>Because <code>(b)</code> dereferences the <code>this</code> pointer (<code>(*this).x = 5;</code>), and <code>this</code> is null, the program enters undefined behavior, as dereferencing null is always said to be undefined behavior.</p>
  
  <p>Does <code>(a)</code> result in undefined behavior? What about if both functions (and <code>x</code>) are static?</p>