http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57010



             Bug #: 57010

           Summary: priority_queue calls self-move-assignment operator

    Classification: Unclassified

           Product: gcc

           Version: 4.7.1

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: libstdc++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: phil...@fb.com





#include <iostream>

#include <queue>



struct A {

  A() { }



  A(const A&) = default;

  A& operator=(const A&) = default;



  A(A&&) = default;

  A& operator=(A&& a) {

    if (this == &a) {

      std::cerr << "?!" << std::endl;

    }

    return *this;

  }



  bool operator<(const A&) const {

    return false;

  }

};



int main() {

  std::priority_queue<A> q;

  q.push(A());

  q.pop();  // prints '?!'

  return 0;

}





std::priority_queue<> calls self-move-assignment when pop() the last element. 

Verified in gcc-4.6.2 and gcc-4.7.1.

Reply via email to