title: c++ access static members using null pointer
body: <p>Recently tried the following program and it compiles, runs fine and produces expected output instead of any runtime error.</p>
  
  <pre><code>#include &lt;iostream&gt;
  class demo
  {
      public:
          static void fun()
          {
              std::cout&lt;&lt;"fun() is called\n";
          }
          static int a;
  };
  int demo::a=9;
  int main()
  {
      demo* d=nullptr;
      d-&gt;fun();
      std::cout&lt;&lt;d-&gt;a;
      return 0;
  }
  </code></pre>
  
  <p>If an uninitialized pointer is used to access class and/or struct members behaviour is undefined, but why it is allowed to access static members using null pointers also. Is there any harm in my program?</p>