title: Why is overriding both the global new operator and the class-specific operator not ambiguous behaviour?
body: <p>Consider the following code:</p>
  
  <pre><code>class Foo 
  {
  public:
      //class-specific
      Foo operator+(Foo&amp; rhs)
      {
         return Foo(); //Just return a temporary
      }
  
      void* operator new(size_t sd)
      {
          return malloc(sd);
      }
  };
  
  //global
  Foo operator+(Foo&amp; lhs, Foo&amp; rhs)
  {
      return Foo();
  }
  
  void* operator new(size_t sd)
  {
      return malloc(sd);
  }
  </code></pre>
  
  <p>This code will not compile, stating the call is ambiguous because it matches two operators:</p>
  
  <pre><code>Foo a, b;
  a + b;
  </code></pre>
  
  <p>But this one with the new operator compiles just fine, and will call the class-specific one. </p>
  
  <pre><code>Foo* a = new Foo();
  </code></pre>
  
  <p>Why doesn't it result in a compile error? Does the compiler treat the new operator differently? (Any citation to the standard would be appreciated.)</p>