Skip to content

Commit ece9862

Browse files
committed
Changes to satisfy GCC's -Wdeprecated-copy in the test suite.
* Add the missing of copy constructor or copy assignment operator to all classes GCC complains about in the warning, for C++11 only (since the deprecation is C++11 and up), with the default meaning that they had since forever. * Add missing move operations to cuda::vector (how did *that* happen?). Bug 200582781 Reviewed-by: Bryce Adelstein Lelbach aka wash <brycelelbach@gmail.com>
1 parent 9d24f55 commit ece9862

24 files changed

+198
-80
lines changed

examples/scan_matrix_by_rows.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <thrust/device_vector.h>
22
#include <thrust/scan.h>
3+
#include <thrust/sequence.h>
34
#include <thrust/iterator/transform_iterator.h>
45
#include <thrust/iterator/counting_iterator.h>
56

@@ -20,7 +21,7 @@ void scan_matrix_by_rows0(thrust::device_vector<int>& u, int n, int m) {
2021

2122
// We can batch the operation using `thrust::inclusive_scan_by_key`, which
2223
// scans each group of consecutive equal keys. All we need to do is generate
23-
// the right key sequence. We want the keys for elements on the same row to
24+
// the right key sequence. We want the keys for elements on the same row to
2425
// be identical.
2526

2627
// So first, we define an unary function object which takes the index of an

examples/uninitialized_vector.cu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ template<typename T>
2929
__host__
3030
~uninitialized_allocator() {}
3131

32+
#if THRUST_CPP_DIALECT >= 2011
33+
uninitialized_allocator & operator=(const uninitialized_allocator &) = default;
34+
#endif
35+
3236
// for correctness, you should also redefine rebind when you inherit
3337
// from an allocator type; this way, if the allocator is rebound somewhere,
3438
// it's going to be rebound to the correct type - and not to its base

testing/fill.cu

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ void TestFillSimple(void)
2222
ASSERT_EQUAL(v[2], 7);
2323
ASSERT_EQUAL(v[3], 7);
2424
ASSERT_EQUAL(v[4], 4);
25-
25+
2626
thrust::fill(v.begin() + 0, v.begin() + 3, (T) 8);
27-
27+
2828
ASSERT_EQUAL(v[0], 8);
2929
ASSERT_EQUAL(v[1], 8);
3030
ASSERT_EQUAL(v[2], 8);
3131
ASSERT_EQUAL(v[3], 7);
3232
ASSERT_EQUAL(v[4], 4);
33-
33+
3434
thrust::fill(v.begin() + 2, v.end(), (T) 9);
35-
35+
3636
ASSERT_EQUAL(v[0], 8);
3737
ASSERT_EQUAL(v[1], 8);
3838
ASSERT_EQUAL(v[2], 9);
3939
ASSERT_EQUAL(v[3], 9);
4040
ASSERT_EQUAL(v[4], 9);
4141

4242
thrust::fill(v.begin(), v.end(), (T) 1);
43-
43+
4444
ASSERT_EQUAL(v[0], 1);
4545
ASSERT_EQUAL(v[1], 1);
4646
ASSERT_EQUAL(v[2], 1);
@@ -70,14 +70,14 @@ void TestFillMixedTypes(void)
7070
Vector v(4);
7171

7272
thrust::fill(v.begin(), v.end(), bool(true));
73-
73+
7474
ASSERT_EQUAL(v[0], 1);
7575
ASSERT_EQUAL(v[1], 1);
7676
ASSERT_EQUAL(v[2], 1);
7777
ASSERT_EQUAL(v[3], 1);
78-
78+
7979
thrust::fill(v.begin(), v.end(), char(20));
80-
80+
8181
ASSERT_EQUAL(v[0], 20);
8282
ASSERT_EQUAL(v[1], 20);
8383
ASSERT_EQUAL(v[2], 20);
@@ -101,17 +101,17 @@ void TestFill(size_t n)
101101
thrust::fill(d_data.begin() + std::min((size_t)117, n), d_data.begin() + std::min((size_t)367, n), (T) 1);
102102

103103
ASSERT_EQUAL(h_data, d_data);
104-
104+
105105
thrust::fill(h_data.begin() + std::min((size_t)8, n), h_data.begin() + std::min((size_t)259, n), (T) 2);
106106
thrust::fill(d_data.begin() + std::min((size_t)8, n), d_data.begin() + std::min((size_t)259, n), (T) 2);
107107

108108
ASSERT_EQUAL(h_data, d_data);
109-
109+
110110
thrust::fill(h_data.begin() + std::min((size_t)3, n), h_data.end(), (T) 3);
111111
thrust::fill(d_data.begin() + std::min((size_t)3, n), d_data.end(), (T) 3);
112112

113113
ASSERT_EQUAL(h_data, d_data);
114-
114+
115115
thrust::fill(h_data.begin(), h_data.end(), (T) 4);
116116
thrust::fill(d_data.begin(), d_data.end(), (T) 4);
117117

@@ -135,18 +135,18 @@ void TestFillNSimple(void)
135135
ASSERT_EQUAL(v[3], 7);
136136
ASSERT_EQUAL(v[4], 4);
137137
ASSERT_EQUAL_QUIET(v.begin() + 4, iter);
138-
138+
139139
iter = thrust::fill_n(v.begin() + 0, 3, (T) 8);
140-
140+
141141
ASSERT_EQUAL(v[0], 8);
142142
ASSERT_EQUAL(v[1], 8);
143143
ASSERT_EQUAL(v[2], 8);
144144
ASSERT_EQUAL(v[3], 7);
145145
ASSERT_EQUAL(v[4], 4);
146146
ASSERT_EQUAL_QUIET(v.begin() + 3, iter);
147-
147+
148148
iter = thrust::fill_n(v.begin() + 2, 3, (T) 9);
149-
149+
150150
ASSERT_EQUAL(v[0], 8);
151151
ASSERT_EQUAL(v[1], 8);
152152
ASSERT_EQUAL(v[2], 9);
@@ -155,7 +155,7 @@ void TestFillNSimple(void)
155155
ASSERT_EQUAL_QUIET(v.end(), iter);
156156

157157
iter = thrust::fill_n(v.begin(), v.size(), (T) 1);
158-
158+
159159
ASSERT_EQUAL(v[0], 1);
160160
ASSERT_EQUAL(v[1], 1);
161161
ASSERT_EQUAL(v[2], 1);
@@ -192,15 +192,15 @@ void TestFillNMixedTypes(void)
192192
Vector v(4);
193193

194194
typename Vector::iterator iter = thrust::fill_n(v.begin(), v.size(), bool(true));
195-
195+
196196
ASSERT_EQUAL(v[0], 1);
197197
ASSERT_EQUAL(v[1], 1);
198198
ASSERT_EQUAL(v[2], 1);
199199
ASSERT_EQUAL(v[3], 1);
200200
ASSERT_EQUAL_QUIET(v.end(), iter);
201-
201+
202202
iter = thrust::fill_n(v.begin(), v.size(), char(20));
203-
203+
204204
ASSERT_EQUAL(v[0], 20);
205205
ASSERT_EQUAL(v[1], 20);
206206
ASSERT_EQUAL(v[2], 20);
@@ -227,19 +227,19 @@ void TestFillN(size_t n)
227227
thrust::fill_n(d_data.begin() + begin_offset, std::min((size_t)367, n) - begin_offset, (T) 1);
228228

229229
ASSERT_EQUAL(h_data, d_data);
230-
230+
231231
begin_offset = std::min<size_t>(8, n);
232232
thrust::fill_n(h_data.begin() + begin_offset, std::min((size_t)259, n) - begin_offset, (T) 2);
233233
thrust::fill_n(d_data.begin() + begin_offset, std::min((size_t)259, n) - begin_offset, (T) 2);
234234

235235
ASSERT_EQUAL(h_data, d_data);
236-
236+
237237
begin_offset = std::min<size_t>(3, n);
238238
thrust::fill_n(h_data.begin() + begin_offset, h_data.size() - begin_offset, (T) 3);
239239
thrust::fill_n(d_data.begin() + begin_offset, d_data.size() - begin_offset, (T) 3);
240240

241241
ASSERT_EQUAL(h_data, d_data);
242-
242+
243243
thrust::fill_n(h_data.begin(), h_data.size(), (T) 4);
244244
thrust::fill_n(d_data.begin(), d_data.size(), (T) 4);
245245

@@ -301,7 +301,7 @@ void TestFillWithTrivialAssignment(void)
301301

302302
thrust::host_vector<T> h(1);
303303
thrust::device_vector<T> d(1);
304-
304+
305305
ASSERT_EQUAL(h[0].x, 0);
306306
ASSERT_EQUAL(h[0].y, 0);
307307
ASSERT_EQUAL(h[0].z, 0);
@@ -334,6 +334,10 @@ struct TypeWithNonTrivialAssigment
334334
__host__ __device__
335335
TypeWithNonTrivialAssigment() : x(0), y(0), z(0) {}
336336

337+
#if THRUST_CPP_DIALECT >= 2011
338+
TypeWithNonTrivialAssigment(const TypeWithNonTrivialAssigment &) = default;
339+
#endif
340+
337341
__host__ __device__
338342
TypeWithNonTrivialAssigment& operator=(const TypeWithNonTrivialAssigment& t)
339343
{
@@ -342,7 +346,7 @@ struct TypeWithNonTrivialAssigment
342346
z = t.x + t.y;
343347
return *this;
344348
}
345-
349+
346350
__host__ __device__
347351
bool operator==(const TypeWithNonTrivialAssigment& t) const
348352
{
@@ -356,7 +360,7 @@ void TestFillWithNonTrivialAssignment(void)
356360

357361
thrust::host_vector<T> h(1);
358362
thrust::device_vector<T> d(1);
359-
363+
360364
ASSERT_EQUAL(h[0].x, 0);
361365
ASSERT_EQUAL(h[0].y, 0);
362366
ASSERT_EQUAL(h[0].z, 0);

testing/swap_ranges.cu

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <unittest/unittest.h>
22
#include <thrust/swap.h>
3-
#include <thrust/iterator/iterator_traits.h>
3+
#include <thrust/iterator/iterator_traits.h>
44
#include <thrust/iterator/retag.h>
55
#include <thrust/system/cpp/memory.h>
66

@@ -68,7 +68,7 @@ void TestSwapRangesSimple(void)
6868
ASSERT_EQUAL(v1[2], 7);
6969
ASSERT_EQUAL(v1[3], 8);
7070
ASSERT_EQUAL(v1[4], 9);
71-
71+
7272
ASSERT_EQUAL(v2[0], 0);
7373
ASSERT_EQUAL(v2[1], 1);
7474
ASSERT_EQUAL(v2[2], 2);
@@ -88,11 +88,11 @@ void TestSwapRanges(const size_t n)
8888
thrust::host_vector<T> h2 = a2;
8989
thrust::device_vector<T> d1 = a1;
9090
thrust::device_vector<T> d2 = a2;
91-
91+
9292
thrust::swap_ranges(h1.begin(), h1.end(), h2.begin());
9393
thrust::swap_ranges(d1.begin(), d1.end(), d2.begin());
9494

95-
ASSERT_EQUAL(h1, a2);
95+
ASSERT_EQUAL(h1, a2);
9696
ASSERT_EQUAL(d1, a2);
9797
ASSERT_EQUAL(h2, a1);
9898
ASSERT_EQUAL(d2, a1);
@@ -147,6 +147,10 @@ struct type_with_swap
147147
return m_x == other.m_x && m_swapped == other.m_swapped;
148148
}
149149

150+
#if THRUST_CPP_DIALECT >= 2011
151+
type_with_swap & operator=(const type_with_swap &) = default;
152+
#endif
153+
150154
int m_x;
151155
bool m_swapped;
152156
};

thrust/detail/config/simple_defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@
2424
#define THRUST_FALSE 0
2525
#define THRUST_TRUE 1
2626

27+
#define THRUST_UNUSED_VAR(expr) do { (void)(expr); } while (0)
28+
2729
#define THRUST_PREVENT_MACRO_SUBSTITUTION
2830

thrust/detail/reference.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ template<typename Element, typename Pointer, typename Derived>
6161
__host__ __device__
6262
explicit reference(const pointer &ptr);
6363

64+
#if THRUST_CPP_DIALECT >= 2011
65+
reference(const reference &) = default;
66+
#endif
67+
6468
template<typename OtherElement, typename OtherPointer, typename OtherDerived>
6569
__host__ __device__
6670
reference(const reference<OtherElement,OtherPointer,OtherDerived> &other,

thrust/detail/tuple.inl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ template <class HT, class TT>
309309
inline __host__ __device__
310310
cons( const cons<HT2, TT2>& u ) : head(u.head), tail(u.tail) {}
311311

312+
#if THRUST_CPP_DIALECT >= 2011
313+
cons(const cons &) = default;
314+
#endif
315+
312316
__thrust_exec_check_disable__
313317
template <class HT2, class TT2>
314318
inline __host__ __device__
@@ -412,6 +416,10 @@ template <class HT>
412416
inline __host__ __device__
413417
cons( const cons<HT2, null_type>& u ) : head(u.head) {}
414418

419+
#if THRUST_CPP_DIALECT >= 2011
420+
cons(const cons &) = default;
421+
#endif
422+
415423
__thrust_exec_check_disable__
416424
template <class HT2>
417425
inline __host__ __device__

thrust/device_allocator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ class device_allocator
130130
__host__
131131
device_allocator(const device_allocator<U>& other) : base(other) {}
132132

133+
#if THRUST_CPP_DIALECT >= 2011
134+
device_allocator & operator=(const device_allocator &) = default;
135+
#endif
136+
133137
/*! Destructor has no effect. */
134138
__host__
135139
~device_allocator() {}

thrust/device_malloc_allocator.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,16 @@ template<typename T>
108108
__host__ __device__
109109
inline device_malloc_allocator(device_malloc_allocator<U> const&) {}
110110

111+
#if THRUST_CPP_DIALECT >= 2011
112+
device_malloc_allocator & operator=(const device_malloc_allocator &) = default;
113+
#endif
114+
111115
/*! Returns the address of an allocated object.
112116
* \return <tt>&r</tt>.
113117
*/
114118
__host__ __device__
115119
inline pointer address(reference r) { return &r; }
116-
120+
117121
/*! Returns the address an allocated object.
118122
* \return <tt>&r</tt>.
119123
*/

0 commit comments

Comments
 (0)