aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test
diff options
context:
space:
mode:
authorGravatar Antonio Sanchez <cantonios@google.com>2021-03-05 12:54:26 -0800
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2021-03-10 16:55:20 +0000
commit543e34ab9dee6004337b7ad912417eb91bf4a0b9 (patch)
treef250fa260325479d4006f0dec77f5ce2bdc009c5 /unsupported/test
parentb8d1857f0d87475016b5c16a6a235efa1fd5e9b5 (diff)
Re-implement move assignments.
The original swap approach leads to potential undefined behavior (reading uninitialized memory) and results in unnecessary copying of data for static storage. Here we pass down the move assignment to the underlying storage. Static storage does a one-way copy, dynamic storage does a swap. Modified the tests to no longer read from the moved-from matrix/tensor, since that can lead to UB. Added a test to ensure we do not access uninitialized memory in a move. Fixes: #2119
Diffstat (limited to 'unsupported/test')
-rw-r--r--unsupported/test/cxx11_tensor_move.cpp5
1 files changed, 0 insertions, 5 deletions
diff --git a/unsupported/test/cxx11_tensor_move.cpp b/unsupported/test/cxx11_tensor_move.cpp
index 0ab2b7786..a2982319f 100644
--- a/unsupported/test/cxx11_tensor_move.cpp
+++ b/unsupported/test/cxx11_tensor_move.cpp
@@ -62,14 +62,9 @@ static void test_move()
moved_tensor3 = std::move(moved_tensor1);
moved_tensor4 = std::move(moved_tensor2);
- VERIFY_IS_EQUAL(moved_tensor1.size(), 8);
- VERIFY_IS_EQUAL(moved_tensor2.size(), 8);
-
for (int i = 0; i < 8; i++)
{
calc_indices(i, x, y, z);
- VERIFY_IS_EQUAL(moved_tensor1(x,y,z), 0);
- VERIFY_IS_EQUAL(moved_tensor2(x,y,z), 0);
VERIFY_IS_EQUAL(moved_tensor3(x,y,z), i);
VERIFY_IS_EQUAL(moved_tensor4(x,y,z), 2 * i);
}