Skip to content

[BUG]: Thrust references are not equally comparable in C++20 #7042

@correaa

Description

@correaa

Is this a duplicate?

Type of Bug

Compile-time Error

Component

Thrust

Describe the bug

I have a function that uses an equal algorithm, and it looks like when I upgrade to c++ the equal algorithm doesn't work because tagged_references don't fulfill the reqs.

All the details are here: https://gitlab.com/correaa/boost-multi/-/jobs/12511993663#L2867

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1587:12: error: no matching function for call to object of type 'std::equal_to<void>'
 1587 |         if (!bool(__binary_pred(*__first1, *__first2)))
      |                   ^~~~~~~~~~~~~
/builds/correaa/boost-multi/include/boost/multi/detail/adl.hpp:139:139: note: in instantiation of function template specialization 'std::equal<thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>, thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>, std::equal_to<void>>' requested here
  139 |         template<         class...As> constexpr auto _(priority<4>/**/,          As&&...args) const BOOST_MULTI_DECLRETURN(                      equal(                      std::forward<As>(args)..., std::equal_to<>{}))  // WORKAROUND makes syntax compatible with boost::ranges::equal if, for some reason, it is included.
      |                                                                                                                                                  ^
/builds/correaa/boost-multi/include/boost/multi/detail/adl.hpp:144:100: note: in instantiation of function template specialization 'boost::multi::adl_equal_t::_<thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>, thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>, thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>>' requested here
  144 |         template<class...As>          constexpr auto operator()(As&&...args) const BOOST_MULTI_DECLRETURN(_(priority<6>{}, std::forward<As>(args)...))
      |                                                                                                           ^
/builds/correaa/boost-multi/include/boost/multi/array_ref.hpp:3651:10: note: in instantiation of function template specialization 'boost::multi::adl_equal_t::operator()<thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>, thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>, thrust::pointer<const thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>>>' requested here
 3651 |                 return adl_equal(
      |                        ^
/builds/correaa/boost-multi/include/boost/multi/adaptors/cuda/cublas/test/all.cu:73:19: note: in instantiation of function template specialization 'boost::multi::operator==<thrust::complex<double>, thrust::pointer<thrust::complex<double>, thrust::cuda_cub::tag, thrust::tagged_reference<thrust::complex<double>, thrust::cuda_cub::tag>>, boost::multi::layout_t<1>>' requested here
   73 |                                 BOOST_TEST(xx == x);
      |                                               ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_function.h:499:2: note: candidate template ignored: substitution failure [with _Tp = reference, _Up = reference]: invalid operands to binary expression ('thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>' and 'thrust::tagged_reference<const thrust::complex<double>, thrust::cuda_cub::tag>')
  499 |         operator()(_Tp&& __t, _Up&& __u) const
      |         ^
  500 |         noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
  501 |         -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
      |                                            ~~

I find a workaround that is to avoid using std::equal_to<>{}, however, it might still be a problem in other contexts.

How to Reproduce

All the details are here: https://gitlab.com/correaa/boost-multi/-/jobs/12511993663#L2867

Expected behavior

code should compile like it did in C++17 mode

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working right.needs triageIssues that require the team's attention

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions