Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit d4b6eaa

Browse files
committed
Iterators: Suppress "reference to temporary" warnings erroneously reported by
MSVC 2013 and 2015. Bug 200385113 git-commit b93a7c51d5eb2259022f35ae5da92e47dbfc66e9 git-author Bryce Adelstein Lelbach aka wash <[email protected]> VDVS: http://ausdvs.nvidia.com/Build_Results?virtualId=1000098256&which_page=current_build ERIS: https://eris-portal.nvidia.com/fromJenkins.jsp?uuid=d22716bf-588d-4e80-8c16-c55f086a3796 Jobs: 200385113-2006 [git-p4: depot-paths = "//sw/gpgpu/thrust/": change = 23593362]
1 parent 4b61388 commit d4b6eaa

14 files changed

+63
-38
lines changed

thrust/iterator/constant_iterator.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace thrust
7171
* #include <thrust/functional.h>
7272
* #include <thrust/device_vector.h>
7373
*
74-
* int main(void)
74+
* int main()
7575
* {
7676
* thrust::device_vector<int> data(4);
7777
* data[0] = 3;
@@ -117,8 +117,8 @@ template<typename Value,
117117
* null constructor.
118118
*/
119119
__host__ __device__
120-
constant_iterator(void)
121-
: super_t(), m_value(){};
120+
constant_iterator()
121+
: super_t(), m_value() {}
122122

123123
/*! Copy constructor copies the value of another \p constant_iterator into this
124124
* \p constant_iterator.
@@ -173,24 +173,24 @@ template<typename Value,
173173
* \return A \c const reference to this \p constant_iterator's constant value.
174174
*/
175175
__host__ __device__
176-
Value const& value(void) const
176+
Value const& value() const
177177
{ return m_value; }
178178

179179
/*! \cond
180180
*/
181181

182182
protected:
183183
__host__ __device__
184-
Value const& value_reference(void) const
184+
Value const& value_reference() const
185185
{ return m_value; }
186186

187187
__host__ __device__
188-
Value & value_reference(void)
188+
Value & value_reference()
189189
{ return m_value; }
190190

191191
private: // Core iterator interface
192192
__host__ __device__
193-
reference dereference(void) const
193+
reference dereference() const
194194
{
195195
return m_value;
196196
}

thrust/iterator/counting_iterator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ namespace thrust
9090
* #include <thrust/functional.h>
9191
* #include <thrust/device_vector.h>
9292
*
93-
* int main(void)
93+
* int main()
9494
* {
9595
* // this example computes indices for all the nonzero values in a sequence
9696
*
@@ -149,7 +149,7 @@ template<typename Incrementable,
149149
* counter using its null constructor.
150150
*/
151151
__host__ __device__
152-
counting_iterator(void){};
152+
counting_iterator() {}
153153

154154
/*! Copy constructor copies the value of another \p counting_iterator into a
155155
* new \p counting_iterator.
@@ -186,7 +186,7 @@ template<typename Incrementable,
186186
*/
187187
private:
188188
__host__ __device__
189-
reference dereference(void) const
189+
reference dereference() const
190190
{
191191
return this->base_reference();
192192
}

thrust/iterator/detail/any_assign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace detail
2727
// a type which may be assigned any other type
2828
struct any_assign
2929
{
30-
inline __host__ __device__ any_assign(void)
30+
inline __host__ __device__ any_assign()
3131
{}
3232

3333
template<typename T>

thrust/iterator/detail/counting_iterator.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ template <typename Incrementable, typename System, typename Traversal, typename
6969
// our implementation departs from Boost's in that counting_iterator::dereference
7070
// returns a copy of its counter, rather than a reference to it. returning a reference
7171
// to the internal state of an iterator causes subtle bugs (consider the temporary
72-
// iterator created in the expression *(iter + i) ) and has no compelling use case
72+
// iterator created in the expression *(iter + i)) and has no compelling use case
7373
typedef thrust::iterator_adaptor<
7474
counting_iterator<Incrementable, System, Traversal, Difference>, // self
7575
Incrementable, // Base

thrust/iterator/detail/join_iterator.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class join_iterator
100100
private:
101101
friend class thrust::iterator_core_access;
102102

103+
// MSVC 2013 and 2015 incorrectly warning about returning a reference to
104+
// a local/temporary here.
105+
// See goo.gl/LELTNp
106+
__THRUST_DISABLE_MSVC_WARNING_BEGIN(4172)
103107

104108
__host__ __device__
105109
typename super_t::reference dereference() const
@@ -108,6 +112,8 @@ class join_iterator
108112
return (i < m_n1) ? m_iter1[i] : static_cast<typename super_t::reference>(m_iter2[i]);
109113
} // end dereference()
110114

115+
__THRUST_DISABLE_MSVC_WARNING_END(4172)
116+
111117

112118
size_type m_n1;
113119
RandomAccessIterator1 m_iter1;

thrust/iterator/detail/reverse_iterator.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@ template<typename BidirectionalIterator>
6464
__host__ __device__
6565
typename reverse_iterator<BidirectionalIterator>::super_t::reference
6666
reverse_iterator<BidirectionalIterator>
67-
::dereference(void) const
67+
::dereference() const
6868
{
6969
return *thrust::detail::prior(this->base());
7070
} // end reverse_iterator::increment()
7171

7272
template<typename BidirectionalIterator>
7373
__host__ __device__
7474
void reverse_iterator<BidirectionalIterator>
75-
::increment(void)
75+
::increment()
7676
{
7777
--this->base_reference();
7878
} // end reverse_iterator::increment()
7979

8080
template<typename BidirectionalIterator>
8181
__host__ __device__
8282
void reverse_iterator<BidirectionalIterator>
83-
::decrement(void)
83+
::decrement()
8484
{
8585
++this->base_reference();
8686
} // end reverse_iterator::decrement()

thrust/iterator/detail/tagged_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ template<typename Iterator, typename Tag>
5151

5252
public:
5353
__host__ __device__
54-
tagged_iterator(void) {}
54+
tagged_iterator() {}
5555

5656
__host__ __device__
5757
explicit tagged_iterator(Iterator x)

thrust/iterator/detail/zip_iterator.inl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace thrust
2626
template<typename IteratorTuple>
2727
__host__ __device__
2828
zip_iterator<IteratorTuple>
29-
::zip_iterator(void)
29+
::zip_iterator()
3030
{
3131
} // end zip_iterator::zip_iterator()
3232

@@ -57,7 +57,7 @@ template<typename IteratorTuple>
5757
template<typename IteratorTuple>
5858
__host__ __device__
5959
const IteratorTuple &zip_iterator<IteratorTuple>
60-
::get_iterator_tuple(void) const
60+
::get_iterator_tuple() const
6161
{
6262
return m_iterator_tuple;
6363
} // end zip_iterator::get_iterator_tuple()
@@ -67,11 +67,13 @@ template<typename IteratorTuple>
6767
typename zip_iterator<IteratorTuple>::super_t::reference
6868
__host__ __device__
6969
zip_iterator<IteratorTuple>
70-
::dereference(void) const
70+
::dereference() const
7171
{
7272
using namespace detail::tuple_impl_specific;
7373

74-
return thrust::detail::tuple_host_device_transform<detail::dereference_iterator::template apply>(get_iterator_tuple(), detail::dereference_iterator());
74+
return thrust::detail::tuple_host_device_transform<
75+
detail::dereference_iterator::template apply
76+
>(get_iterator_tuple(), detail::dereference_iterator());
7577
} // end zip_iterator::dereference()
7678

7779

@@ -100,7 +102,7 @@ __host__ __device__
100102
template<typename IteratorTuple>
101103
__host__ __device__
102104
void zip_iterator<IteratorTuple>
103-
::increment(void)
105+
::increment()
104106
{
105107
using namespace detail::tuple_impl_specific;
106108
tuple_for_each(m_iterator_tuple, detail::increment_iterator());
@@ -110,7 +112,7 @@ __host__ __device__
110112
template<typename IteratorTuple>
111113
__host__ __device__
112114
void zip_iterator<IteratorTuple>
113-
::decrement(void)
115+
::decrement()
114116
{
115117
using namespace detail::tuple_impl_specific;
116118
tuple_for_each(m_iterator_tuple, detail::decrement_iterator());

thrust/iterator/discard_iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace thrust
5353
* #include <thrust/reduce.h>
5454
* #include <thrust/device_vector.h>
5555
*
56-
* int main(void)
56+
* int main()
5757
* {
5858
* thrust::device_vector<int> keys(7), values(7);
5959
*
@@ -132,7 +132,7 @@ template<typename System = use_default>
132132

133133
private: // Core iterator interface
134134
__host__ __device__
135-
reference dereference(void) const
135+
reference dereference() const
136136
{
137137
return m_element;
138138
}

thrust/iterator/permutation_iterator.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,20 @@ template <typename ElementIterator,
167167
/*! \cond
168168
*/
169169
private:
170+
// MSVC 2013 and 2015 incorrectly warning about returning a reference to
171+
// a local/temporary here.
172+
// See goo.gl/LELTNp
173+
__THRUST_DISABLE_MSVC_WARNING_BEGIN(4172)
174+
170175
__thrust_exec_check_disable__
171176
__host__ __device__
172177
typename super_t::reference dereference() const
173178
{
174179
return *(m_element_iterator + *this->base());
175180
}
176181

182+
__THRUST_DISABLE_MSVC_WARNING_END(4172)
183+
177184
// make friends for the copy constructor
178185
template<typename,typename> friend class permutation_iterator;
179186

thrust/iterator/reverse_iterator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ template<typename BidirectionalIterator>
160160
/*! Default constructor does nothing.
161161
*/
162162
__host__ __device__
163-
reverse_iterator(void) {}
163+
reverse_iterator() {}
164164

165165
/*! \p Constructor accepts a \c BidirectionalIterator pointing to a range
166166
* for this \p reverse_iterator to reverse.
@@ -195,13 +195,13 @@ template<typename BidirectionalIterator>
195195
private:
196196
__thrust_exec_check_disable__
197197
__host__ __device__
198-
typename super_t::reference dereference(void) const;
198+
typename super_t::reference dereference() const;
199199

200200
__host__ __device__
201-
void increment(void);
201+
void increment();
202202

203203
__host__ __device__
204-
void decrement(void);
204+
void decrement();
205205

206206
__host__ __device__
207207
void advance(typename super_t::difference_type n);

thrust/iterator/transform_iterator.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace thrust
7777
* }
7878
* };
7979
*
80-
* int main(void)
80+
* int main()
8181
* {
8282
* thrust::device_vector<float> v(4);
8383
* v[0] = 1.0f;
@@ -120,7 +120,7 @@ namespace thrust
120120
* }
121121
* };
122122
*
123-
* int main(void)
123+
* int main()
124124
* {
125125
* // initialize a device array
126126
* thrust::device_vector<float> v(4);
@@ -161,7 +161,7 @@ namespace thrust
161161
* }
162162
* };
163163
*
164-
* int main(void)
164+
* int main()
165165
* {
166166
* thrust::device_vector<float> v(4);
167167
* v[0] = 1.0f;
@@ -296,16 +296,24 @@ template <class AdaptableUnaryFunction, class Iterator, class Reference = use_de
296296
return *this;
297297
}
298298

299+
// MSVC 2013 and 2015 incorrectly warning about returning a reference to
300+
// a local/temporary here.
301+
// See goo.gl/LELTNp
302+
__THRUST_DISABLE_MSVC_WARNING_BEGIN(4172)
303+
299304
__thrust_exec_check_disable__
300305
__host__ __device__
301306
typename super_t::reference dereference() const
302-
{
303-
// create a temporary to allow iterators with wrapped references to convert to their value type before calling m_f
304-
// note that this disallows non-constant operations through m_f
307+
{
308+
// Create a temporary to allow iterators with wrapped references to
309+
// convert to their value type before calling m_f. Note that this
310+
// disallows non-constant operations through m_f.
305311
typename thrust::iterator_value<Iterator>::type x = *this->base();
306312
return m_f(x);
307313
}
308314

315+
__THRUST_DISABLE_MSVC_WARNING_END(4172)
316+
309317
// tag this as mutable per Dave Abrahams in this thread:
310318
// http://lists.boost.org/Archives/boost/2004/05/65332.php
311319
mutable AdaptableUnaryFunction m_f;

thrust/iterator/transform_output_iterator.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace thrust
6363
* }
6464
* };
6565
*
66-
* int main(void)
66+
* int main()
6767
* {
6868
* thrust::device_vector<float> v(4);
6969
*
@@ -125,7 +125,9 @@ template <typename UnaryFunction, typename OutputIterator>
125125
__host__ __device__
126126
typename super_t::reference dereference() const
127127
{
128-
return detail::transform_output_iterator_proxy<UnaryFunction, OutputIterator>(this->base_reference(), fun);
128+
return detail::transform_output_iterator_proxy<
129+
UnaryFunction, OutputIterator
130+
>(this->base_reference(), fun);
129131
}
130132

131133
UnaryFunction fun;

thrust/iterator/zip_iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace thrust
108108
* #include <thrust/tuple.h>
109109
* #include <thrust/device_vector.h>
110110
*
111-
* int main(void)
111+
* int main()
112112
* {
113113
* thrust::device_vector<int> int_in(3), int_out(3);
114114
* int_in[0] = 0;
@@ -144,7 +144,7 @@ template <typename IteratorTuple>
144144
/*! Null constructor does nothing.
145145
*/
146146
inline __host__ __device__
147-
zip_iterator(void);
147+
zip_iterator();
148148

149149
/*! This constructor creates a new \p zip_iterator from a
150150
* \p tuple of iterators.

0 commit comments

Comments
 (0)