Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

thrust::device_reference<void> should be impossible #162

Closed
jaredhoberock opened this Issue Jun 20, 2012 · 3 comments

Comments

Projects
None yet
1 participant
Owner

jaredhoberock commented Jun 20, 2012

thrust::device_ptr<void>'s reference type probably ought to be void, and should not be dereferenceable.

It can cause problems right now, as the following program demonstrates:

#include <thrust/device_ptr.h>
#include <thrust/device_reference.h>
#include <thrust/memory.h>

template<typename T>
void foo(T) {}

int main()
{
  thrust::pointer<void, thrust::device_system_tag, thrust::device_reference<void>, thrust::device_ptr<void> > ptr;

  foo(ptr);

  return 0;
}

If foo is removed, no error occurs. It's unclear to me why the invocation of foo causes device_reference<void>'s instantiation instead of the line above.

Owner

jaredhoberock commented Jun 20, 2012

It might be better to address this inside reference<void> than in pointer<void> -- it would be difficult to patch iterator_adaptor et al to work with ptrs to void.

Owner

jaredhoberock commented Jun 21, 2012

Perhaps the pointer's copy constructor (it would get instantiated when invoking foo) causes a problem.

Owner

jaredhoberock commented Jan 11, 2014

The current version of the code seems to do the right thing. thrust::device_ptr<void>'s reference type is void. Closing as invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment