Should a compiler dereference pointers to objects that do not exist?

  class A
  {
     int number;

   public:
     A (int n) { number = n; }
     int getNumber () { return number; }
  };

  // Some compilers allow this, some do not
  // This is considered dangerous - although code may seem to
  // work initially, in the long term errors will surely arise 
  void main ()
  {
     A *a = NULL;
     cout << "Result: " << a->getNumber() << "\n";
  }