Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile error when dereferencing a strided_iterator #851

Open
michael-brade opened this issue Sep 24, 2020 · 1 comment
Open

compile error when dereferencing a strided_iterator #851

michael-brade opened this issue Sep 24, 2020 · 1 comment

Comments

@michael-brade
Copy link

It is not possible to compile a program that dereferences a strided_iterator:

boost::compute::int_ data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
auto it = boost::compute::make_strided_iterator(data, 3);
BOOST_CHECK_EQUAL(*it, 1);

That results in:

test_strided_iterator.cpp:22:
/compute/include/boost/compute/iterator/strided_iterator.hpp: In instantiation of ‘boost::compute::strided_iterator<Iterator>::reference boost::compute::strided_iterator<Iterator>::dereference() const [with Iterator = int*; boost::compute::strided_iterator<Iterator>::reference = int&]’:
/usr/include/boost/iterator/iterator_facade.hpp:550:31:   required from ‘static typename Facade::reference boost::iterators::iterator_core_access::dereference(const Facade&) [with Facade = boost::compute::strided_iterator<int*>; typename Facade::reference = int&]’
/usr/include/boost/iterator/iterator_facade.hpp:656:53:   required from ‘boost::iterators::detail::iterator_facade_base<Derived, Value, CategoryOrTraversal, Reference, Difference, false, false>::reference boost::iterators::detail::iterator_facade_base<Derived, Value, CategoryOrTraversal, Reference, Difference, false, false>::operator*() const [with Derived = boost::compute::strided_iterator<int*>; Value = int; CategoryOrTraversal = std::random_access_iterator_tag; Reference = int&; Difference = long int; boost::iterators::detail::iterator_facade_base<Derived, Value, CategoryOrTraversal, Reference, Difference, false, false>::reference = int&]’
/compute/test/test_strided_iterator.cpp:120:3:   required from here
/compute/include/boost/compute/iterator/strided_iterator.hpp:187:16: error: value-initialization of reference type ‘boost::compute::strided_iterator<int*>::reference’ {aka ‘int&’}
  187 |         return reference();
      |                ^~~~~~~~~~~
make[3]: *** [test/CMakeFiles/test_strided_iterator.dir/build.make:82: test/CMakeFiles/test_strided_iterator.dir/test_strided_iterator.cpp.o] Fehler 1
make[2]: *** [CMakeFiles/Makefile2:3532: test/CMakeFiles/test_strided_iterator.dir/all] Fehler 2
@michael-brade
Copy link
Author

I will create a pull request in the next hour.

michael-brade added a commit to michael-brade/compute that referenced this issue Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant