diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-04-18 15:02:57 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-04-18 15:02:57 +0000 |
commit | ab65a6f560438af4eb60aa0d66a44c044debf37b (patch) | |
tree | f1fd9fe7f8bb6a00a38f9a048b24887f8d79014b /libcxx/include/vector | |
parent | cf7c55ebcceb9921c24cfa76006158cf368991cd (diff) | |
download | bcm5719-llvm-ab65a6f560438af4eb60aa0d66a44c044debf37b.tar.gz bcm5719-llvm-ab65a6f560438af4eb60aa0d66a44c044debf37b.zip |
After years of telling people: 'If you ever find any of my code that self-move-assigns, send me a bug report.' Somebody finally took me up on it. vector::erase(begin(), begin()) does a self-move-assign of every element in the vector, leaving all of those elements in an unspecified state. I checked the other containers for this same bug and did not find it. Added test case.
llvm-svn: 179760
Diffstat (limited to 'libcxx/include/vector')
-rw-r--r-- | libcxx/include/vector | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libcxx/include/vector b/libcxx/include/vector index d1bc23e6a81..e04c2673b2e 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -1615,7 +1615,8 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); pointer __p = this->__begin_ + (__first - begin()); iterator __r = __make_iter(__p); - this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); + if (__first != __last) + this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); return __r; } |