1
0
forked from boostorg/move

Fixes #26 ("Invalid iterator increment/decrement in the last iteration of adaptive_sort_combine_blocks")

This commit is contained in:
Ion Gaztañaga
2019-04-24 20:59:00 +02:00
parent f363c21df8
commit c283a2f123
3 changed files with 16 additions and 3 deletions

View File

@ -802,6 +802,13 @@ Special thanks to:
[section:release_notes Release Notes]
[section:release_notes_boost_1_71 Boost 1.71 Release]
* Fixed bugs:
* [@https://github.com/boostorg/move/issues/26 Git Issue #26: ['"Invalid iterator increment/decrement in the last iteration of adaptive_sort_combine_blocks"]].
[endsect]
[section:release_notes_boost_1_70 Boost 1.70 Release]
* Removed support for deprecated GCC compilers.

View File

@ -180,7 +180,7 @@ void adaptive_sort_combine_blocks
size_type const max_i = n_reg_combined + (l_irreg_combined != 0);
if(merge_left || !use_buf) {
for( size_type combined_i = 0; combined_i != max_i; ++combined_i, combined_first += l_reg_combined) {
for( size_type combined_i = 0; combined_i != max_i; ) {
//Now merge blocks
bool const is_last = combined_i==n_reg_combined;
size_type const l_cur_combined = is_last ? l_irreg_combined : l_reg_combined;
@ -202,11 +202,15 @@ void adaptive_sort_combine_blocks
(keys, key_comp, combined_first, l_block, 0u, n_block_a, n_block_b, l_irreg2, comp, xbuf_used);
}
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" After merge_blocks_L: ", len + l_block);
++combined_i;
if(combined_i != max_i)
combined_first += l_reg_combined;
}
}
else{
combined_first += l_reg_combined*(max_i-1);
for( size_type combined_i = max_i; combined_i--; combined_first -= l_reg_combined) {
for( size_type combined_i = max_i; combined_i; ) {
--combined_i;
bool const is_last = combined_i==n_reg_combined;
size_type const l_cur_combined = is_last ? l_irreg_combined : l_reg_combined;
@ -222,6 +226,8 @@ void adaptive_sort_combine_blocks
merge_blocks_right
(keys, key_comp, combined_first, l_block, n_block_a, n_block_b, l_irreg2, comp, xbuf_used);
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" After merge_blocks_R: ", len + l_block);
if(combined_i)
combined_first -= l_reg_combined;
}
}
}

View File

@ -174,7 +174,7 @@ ForwardOutputIt1 inplace_set_unique_difference
++first2;
}
else if (comp(*first1, *first2)){
//skip any adjacent equivalent elementin range 1
//skip any adjacent equivalent element in range 1
ForwardOutputIt1 result = first1;
if (++first1 != last1 && !comp(*result, *first1)) {
//Some elements from range 1 must be skipped, no longer an inplace operation