Commit 53426b63 by Ville Voutilainen Committed by Ville Voutilainen

PR libstdc++/78389 fix backwards size adjustments.

PR libstdc++/78389
* include/bits/list.tcc (merge(list&&)): Fix backwards size adjustments.
(merge(list&&, _StrictWeakOrdering)): Likewise.
* testsuite/23_containers/list/operations/78389.cc: Add
better test for the sizes.

From-SVN: r244490
parent 7cefdfd5
2017-01-16 Ville Voutilainen <ville.voutilainen@gmail.com>
PR libstdc++/78389
* include/bits/list.tcc (merge(list&&)): Fix backwards size adjustments.
(merge(list&&, _StrictWeakOrdering)): Likewise.
* testsuite/23_containers/list/operations/78389.cc: Add
better test for the sizes.
2017-01-14 Jonathan Wakely <jwakely@redhat.com>
* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
......
......@@ -406,8 +406,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__catch(...)
{
size_t __dist = std::distance(__first2, __last2);
this->_M_inc_size(__dist);
__x._M_set_size(__orig_size - __dist);
this->_M_inc_size(__orig_size - __dist);
__x._M_set_size(__dist);
__throw_exception_again;
}
}
......@@ -454,8 +454,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__catch(...)
{
size_t __dist = std::distance(__first2, __last2);
this->_M_inc_size(__dist);
__x._M_set_size(__orig_size - __dist);
this->_M_inc_size(__orig_size - __dist);
__x._M_set_size(__dist);
__throw_exception_again;
}
}
......
......@@ -57,18 +57,20 @@ int main()
std::list<int> a{1, 2, 3, 4};
std::list<int> b{5, 6, 7, 8, 9, 10, 11, 12};
try {
a.merge(b, ThrowingComparator{5});
a.merge(b, ThrowingComparator{4});
} catch (...) {
}
VERIFY(a.size() == 8 && b.size() == 4);
VERIFY(a.size() == std::distance(a.begin(), a.end()) &&
b.size() == std::distance(b.begin(), b.end()));
std::list<X> ax{1, 2, 3, 4};
std::list<X> bx{5, 6, 7, 8, 9, 10, 11, 12};
throw_after_X = 5;
throw_after_X = 4;
try {
ax.merge(bx);
} catch (...) {
}
VERIFY(ax.size() == 8 && bx.size() == 4);
VERIFY(ax.size() == std::distance(ax.begin(), ax.end()) &&
bx.size() == std::distance(bx.begin(), bx.end()));
std::list<int> ay{5, 6, 7, 8, 9, 10, 11, 12};
try {
ay.sort(ThrowingComparator{5});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment