-
Notifications
You must be signed in to change notification settings - Fork 351
Open
Labels
thrustFor all items related to Thrust.For all items related to Thrust.
Description
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
Type of Bug
Compile-time Error
Component
Thrust
Describe the bug
Casting the result of dereferencing a zip_iterator to its value type leads a compilation error for certain types, but not others. A minimal reproducer is shown below
How to Reproduce
Please see the godbolt reproducer link below.
Defining T in the minimal reproducer to contain thrust::tuple<double> triggers a compilation error, while various other cases do not. The failures and non-failures are consistent between g++ and clang++
#define THRUST_DEVICE_SYSTEM 4
#include <thrust/tuple.h>
#include <thrust/device_vector.h>
#include <thrust/iterator/zip_iterator.h>
int main(int argc, char** argv)
{
// FAILURES:
using T = thrust::tuple<double>;
//using T = thrust::tuple<thrust::tuple<double>,double>;
// WORKS:
//using T = double;
//using T = thrust::tuple<double,double>;
//using T = thrust::tuple<thrust::tuple<double,double>,double>;
thrust::device_vector<T> data(10);
auto a = thrust::make_zip_iterator(data.begin());
static_assert(std::is_same_v<thrust::tuple<T>, ::cuda::std::iter_value_t<decltype(a)>>); // success
auto b = a[0];
static_assert(std::is_same_v<thrust::detail::tuple_of_iterator_references<thrust::device_reference<T>>, decltype(b)>); // success
auto c = thrust::tuple<T>(b); // errors for the cases above
return 0;
}
Expected behavior
It should compile, instead it errors if the the type T contains thrust::tuple<double>
In file included from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/internal_functional.h:23,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/system/detail/generic/copy.inl:15,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/system/detail/generic/copy.h:30,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/copy.inl:20,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/copy.h:57,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/allocator/copy_construct_range.h:17,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/contiguous_storage.inl:16,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/contiguous_storage.h:214,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/detail/vector_base.h:21,
from /opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/device_vector.h:20,
from <source>:3:
/opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/iterator/detail/tuple_of_iterator_references.h: In instantiation of 'U thrust::detail::maybe_unwrap_nested<U, T>::operator()(const T&) const [with U = double; T = thrust::device_reference<cuda::std::__4::tuple<double> >]':
/opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/iterator/detail/tuple_of_iterator_references.h:118:42: required from 'constexpr cuda::std::__4::tuple<_Args1 ...> thrust::detail::tuple_of_iterator_references<Ts>::__to_tuple(cuda::std::__4::__tuple_indices<_Indices ...>) const [with Us = {double}; long unsigned int ...Id = {0}; Ts = {thrust::device_reference<cuda::std::__4::tuple<double> >}]'
118 | return {maybe_unwrap_nested<Us, Ts>{}(::cuda::std::get<Id>(*this))...};
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/iterator/detail/tuple_of_iterator_references.h:104:29: required from here
104 | return __to_tuple<Us...>(typename ::cuda::std::__make_tuple_indices<sizeof...(Ts)>::type{});
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/cccl/trunk/thrust/thrust/iterator/detail/tuple_of_iterator_references.h:36:12: error: cannot convert 'const thrust::device_reference<cuda::std::__4::tuple<double> >' to 'double' in return
36 | return t;
| ^
Compiler returned: 1
Reproduction link
https://godbolt.org/z/nhhf6xPra
Operating System
No response
nvidia-smi output
No response
NVCC version
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
thrustFor all items related to Thrust.For all items related to Thrust.
Type
Projects
Status
Todo