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

[FEA]: Improve compilation error message of cuda::std::apply with wrong arguments #2753

Open
1 task done
pciolkosz opened this issue Nov 8, 2024 · 0 comments
Open
1 task done
Labels
feature request New feature or request.

Comments

@pciolkosz
Copy link
Contributor

Is this a duplicate?

Area

libcu++

Is your feature request related to a problem? Please describe.

Error message when cuda::std::apply gets a function that is not possible to be called with the supplied tuple is not helpful with finding out what went wrong. This is especially problematic with function templates because apply needs instantiated functions and it's easy to make a mistake.

Consider the following example with a bug, where a function was meant to be called with a tuple of two integers: https://godbolt.org/z/76vbcsMWM

When std::apply/tuple is used, the error message is immediately clear:

/opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/tuple(1723): error: no instance of function template "std::__invoke" matches the argument list
            argument types are: (void (int &&, int &&), const int, const int)
        return std::__invoke(std::forward<_Fn>(__f),

I tried to call void (int &&, int &&) with const int, const int, so my template instantiation is wrong.

With cuda::std::apply/tuple, the error message seems completely not related to the problem:

/opt/compiler-explorer/cuda/12.6.1/bin/../targets/x86_64-linux/include/cuda/std/detail/libcxx/include/tuple(1297): error: function "cuda::std::__4::__nat::~__nat() noexcept" (declared at line 30 of /opt/compiler-explorer/cuda/12.6.1/bin/../targets/x86_64-linux/include/cuda/std/__type_traits/nat.h) cannot be referenced -- it is a deleted function
  __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, __tuple_indices<_Id...>) noexcept(noexcept(::cuda::std::__4::__invoke(::cuda::std::__4::forward<_Fn>(__f), ::cuda::std::__4::get<_Id>(::cuda::std::__4::forward<_Tuple>(__t))...))) { return ::cuda::std::__4::__invoke(::cuda::std::__4::forward<_Fn>(__f), ::cuda::std::__4::get<_Id>(::cuda::std::__4::forward<_Tuple>(__t))...); }
                                                                                                                   ^
          detected during:
            instantiation of "decltype(auto) cuda::std::__4::__apply_tuple_impl(_Fn &&, _Tuple &&, cuda::std::__4::__tuple_indices<_Id...>) [with _Fn=void (&)(int &&, int &&), _Tuple=const cuda::std::__4::tuple<int, int> &, _Id=<0UL, 1UL>]" at line 1302
            instantiation of "decltype(auto) cuda::std::__4::apply(_Fn &&, _Tuple &&) [with _Fn=void (&)(int &&, int &&), _Tuple=const cuda::std::__4::tuple<int, int> &]" at line 15 of <source>
            instantiation of "void bar(const cuda::std::__4::tuple<Ts...> &) [with Ts=<int, int>]" at line 20 of <source>

/opt/compiler-explorer/cuda/12.6.1/bin/../targets/x86_64-linux/include/cuda/std/detail/libcxx/include/tuple(1297): error: "cuda::std::__4::__nat::~__nat() noexcept" (declared at line 30 of /opt/compiler-explorer/cuda/12.6.1/bin/../targets/x86_64-linux/include/cuda/std/__type_traits/nat.h), required for copy that was eliminated, cannot be referenced -- it is a deleted function
  __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, __tuple_indices<_Id...>) noexcept(noexcept(::cuda::std::__4::__invoke(::cuda::std::__4::forward<_Fn>(__f), ::cuda::std::__4::get<_Id>(::cuda::std::__4::forward<_Tuple>(__t))...))) { return ::cuda::std::__4::__invoke(::cuda::std::__4::forward<_Fn>(__f), ::cuda::std::__4::get<_Id>(::cuda::std::__4::forward<_Tuple>(__t))...); }

Describe the solution you'd like

It would be great to generate a more helpful error message in this case, one that references the function and argument types, not just the still packed tuple type and complaining about some deleted destructor.

Describe alternatives you've considered

No response

Additional context

No response

@pciolkosz pciolkosz added the feature request New feature or request. label Nov 8, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request.
Projects
Status: Todo
Development

No branches or pull requests

1 participant