This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/57010] New: priority_queue calls self-move-assignment operator
- From: "philipp at fb dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Apr 2013 22:20:02 +0000
- Subject: [Bug libstdc++/57010] New: priority_queue calls self-move-assignment operator
- Auto-submitted: auto-generated
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.