This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/57010] New: priority_queue calls self-move-assignment operator


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: unassigned@gcc.gnu.org
        ReportedBy: philipp@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]