title: std::sort fails on std:vector of pointers
body: <p>The following code crashes while sorting the vector.</p>
  
  <pre><code>#include&lt;cstdio&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  using namespace std;
  
  struct Foo
  {
      int x;
      // int y;
      Foo() : x(0) {}
  };
  
  struct Cmp
  {
      bool operator() (Foo* p1, Foo *p2) const
      {
          if (p1-&gt;x != p2-&gt;x) return p1-&gt;x &lt; p2-&gt;x;
          // if (p1-&gt;y != p2-&gt;y) return p1-&gt;y &lt; p2-&gt;y;
          return true;
      }
  };
  
  int main()
  {
      vector&lt;Foo*&gt; v;
      for (int i=0; i&lt;17; i++) // weird thing, doesn't crash if
                               // I put a number less than 17 !!!
      {
          Foo *ptr = new Foo();
          if (ptr) v.push_back(ptr);
      }
      sort(v.begin(), v.end(), Cmp());
  
      return 0;
  }
  </code></pre>
  
  <p>Why is this so?</p>