Skip to content

Commit 89914d3

Browse files
authored
Merge pull request TheHPXProject#6997 from Sahilll10/fix-move-algorithm-tests
tests: fix self-copy UB in move algorithm tests causing occasional segfault
2 parents 024a112 + d3485e6 commit 89914d3

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

libs/core/algorithms/tests/unit/algorithms/move.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ void test_move(IteratorTag)
3333
std::iota(std::begin(c), std::end(c), gen());
3434
hpx::move(iterator(std::begin(c)), iterator(std::end(c)), std::begin(d));
3535

36-
//copy contents of d back into c for testing
37-
std::copy(std::begin(d), std::end(d), std::begin(d));
36+
// copy contents of d back into c for testing
37+
std::copy(std::begin(d), std::end(d), std::begin(c));
3838

3939
std::size_t count = 0;
4040
HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),
@@ -61,8 +61,8 @@ void test_move(ExPolicy policy, IteratorTag)
6161
hpx::move(
6262
policy, iterator(std::begin(c)), iterator(std::end(c)), std::begin(d));
6363

64-
//copy contents of d back into c for testing
65-
std::copy(std::begin(d), std::end(d), std::begin(d));
64+
// copy contents of d back into c for testing
65+
std::copy(std::begin(d), std::end(d), std::begin(c));
6666

6767
std::size_t count = 0;
6868
HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),

libs/core/algorithms/tests/unit/algorithms/move_sender.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ void test_move_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
4646
std::begin(d)) |
4747
hpx::move(ex_policy.on(exec)));
4848

49-
//copy contents of d back into c for testing
50-
std::copy(std::begin(d), std::end(d), std::begin(d));
49+
// copy contents of d back into c for testing
50+
std::copy(std::begin(d), std::end(d), std::begin(c));
5151

5252
std::size_t count = 0;
5353
HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),

libs/core/algorithms/tests/unit/container_algorithms/move_range.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ void test_move(IteratorTag)
3232
std::iota(std::begin(c), std::end(c), std::rand());
3333
hpx::ranges::move(c, std::begin(d));
3434

35-
//copy contents of d back into c for testing
36-
std::copy(std::begin(d), std::end(d), std::begin(d));
35+
// copy contents of d back into c for testing
36+
std::copy(std::begin(d), std::end(d), std::begin(c));
3737

3838
std::size_t count = 0;
3939
HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),
@@ -60,8 +60,8 @@ void test_move(ExPolicy policy, IteratorTag)
6060
std::iota(std::begin(c), std::end(c), std::rand());
6161
hpx::ranges::move(policy, c, std::begin(d));
6262

63-
//copy contents of d back into c for testing
64-
std::copy(std::begin(d), std::end(d), std::begin(d));
63+
// copy contents of d back into c for testing
64+
std::copy(std::begin(d), std::end(d), std::begin(c));
6565

6666
std::size_t count = 0;
6767
HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),

0 commit comments

Comments
 (0)