summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-03-17 20:42:45 +0000
committerdim <dim@FreeBSD.org>2014-03-17 20:42:45 +0000
commitf674f353eee112692d83f39cb1f07f1cbb25380a (patch)
treea3b093a3a2b5ebd33df285e2764647ac9179618e
parent78a6a604266b47f384179179d5e7c8f3677dfb5d (diff)
downloadFreeBSD-src-f674f353eee112692d83f39cb1f07f1cbb25380a.zip
FreeBSD-src-f674f353eee112692d83f39cb1f07f1cbb25380a.tar.gz
MFC r263120:
Pull in r201021 from upstream libc++ trunk: Fix for PR18735 - self-assignment for map/multimap gives incorrect results in C++03 (Please note: that is an LLVM PR identifier, not a FreeBSD one.) Reported by: rakuco
-rw-r--r--contrib/libc++/include/map20
-rw-r--r--contrib/libc++/include/unordered_map28
2 files changed, 28 insertions, 20 deletions
diff --git a/contrib/libc++/include/map b/contrib/libc++/include/map
index 009e8e2..9779b70 100644
--- a/contrib/libc++/include/map
+++ b/contrib/libc++/include/map
@@ -884,10 +884,12 @@ public:
#if __cplusplus >= 201103L
__tree_ = __m.__tree_;
#else
- __tree_.clear();
- __tree_.value_comp() = __m.__tree_.value_comp();
- __tree_.__copy_assign_alloc(__m.__tree_);
- insert(__m.begin(), __m.end());
+ if (this != &__m) {
+ __tree_.clear();
+ __tree_.value_comp() = __m.__tree_.value_comp();
+ __tree_.__copy_assign_alloc(__m.__tree_);
+ insert(__m.begin(), __m.end());
+ }
#endif
return *this;
}
@@ -1616,10 +1618,12 @@ public:
#if __cplusplus >= 201103L
__tree_ = __m.__tree_;
#else
- __tree_.clear();
- __tree_.value_comp() = __m.__tree_.value_comp();
- __tree_.__copy_assign_alloc(__m.__tree_);
- insert(__m.begin(), __m.end());
+ if (this != &__m) {
+ __tree_.clear();
+ __tree_.value_comp() = __m.__tree_.value_comp();
+ __tree_.__copy_assign_alloc(__m.__tree_);
+ insert(__m.begin(), __m.end());
+ }
#endif
return *this;
}
diff --git a/contrib/libc++/include/unordered_map b/contrib/libc++/include/unordered_map
index 78fee48..4e2298b 100644
--- a/contrib/libc++/include/unordered_map
+++ b/contrib/libc++/include/unordered_map
@@ -831,12 +831,14 @@ public:
#if __cplusplus >= 201103L
__table_ = __u.__table_;
#else
- __table_.clear();
- __table_.hash_function() = __u.__table_.hash_function();
- __table_.key_eq() = __u.__table_.key_eq();
- __table_.max_load_factor() = __u.__table_.max_load_factor();
- __table_.__copy_assign_alloc(__u.__table_);
- insert(__u.begin(), __u.end());
+ if (this != &__u) {
+ __table_.clear();
+ __table_.hash_function() = __u.__table_.hash_function();
+ __table_.key_eq() = __u.__table_.key_eq();
+ __table_.max_load_factor() = __u.__table_.max_load_factor();
+ __table_.__copy_assign_alloc(__u.__table_);
+ insert(__u.begin(), __u.end());
+ }
#endif
return *this;
}
@@ -1567,12 +1569,14 @@ public:
#if __cplusplus >= 201103L
__table_ = __u.__table_;
#else
- __table_.clear();
- __table_.hash_function() = __u.__table_.hash_function();
- __table_.key_eq() = __u.__table_.key_eq();
- __table_.max_load_factor() = __u.__table_.max_load_factor();
- __table_.__copy_assign_alloc(__u.__table_);
- insert(__u.begin(), __u.end());
+ if (this != &__u) {
+ __table_.clear();
+ __table_.hash_function() = __u.__table_.hash_function();
+ __table_.key_eq() = __u.__table_.key_eq();
+ __table_.max_load_factor() = __u.__table_.max_load_factor();
+ __table_.__copy_assign_alloc(__u.__table_);
+ insert(__u.begin(), __u.end());
+ }
#endif
return *this;
}
OpenPOWER on IntegriCloud