ADL fails with when_all

Issue #512 resolved
Colin MacLean created an issue

The UPC++ specification defines upcxx::future and upcxx::when_all. With these definitions, the expectation is for ADL to trigger:

#include <upcxx/upcxx.hpp>

int main(int argc, char* argv[])
{
  upcxx::init();
  auto fut = upcxx::make_future(42);
  when_all(fut);
  upcxx::finalize();
  return 0;
}

However, because upcxx::future is internally defined as an alias to a type of upcxx::detail::future1, the wrong namespace is used for ADL, leading to an unexpected error:

adl.cpp:7:15: error: too many arguments to function ‘upcxx::detail::future1<upcxx::detail::future_kind_result> upcxx::detail::when_all()’
    7 |   when_all(fut);
      |               ^
In file included from /home/colin/upcxx/build3/bld/upcxx.assert1.optlev0.dbgsym1.gasnet_seq.smp/include/upcxx/future.hpp:11,
                 from /home/colin/upcxx/build3/bld/upcxx.assert1.optlev0.dbgsym1.gasnet_seq.smp/include/upcxx/backend.hpp:5,
                 from /home/colin/upcxx/build3/bld/upcxx.assert1.optlev0.dbgsym1.gasnet_seq.smp/include/upcxx/allocate.hpp:8,
                 from /home/colin/upcxx/build3/bld/upcxx.assert1.optlev0.dbgsym1.gasnet_seq.smp/include/upcxx/upcxx.hpp:5,
                 from adl.cpp:1:
/home/colin/upcxx/build3/bld/upcxx.assert1.optlev0.dbgsym1.gasnet_seq.smp/include/upcxx/future/when_all.hpp:70:17: note: declared here
   70 |     inline auto when_all() -> decltype(detail::make_fast_future()) {

This bug is made more significant by the fact that it may become customary to invoke std::when_all unqualified to trigger customization of this functionality with Executors. upcxx::when_all should similarly be invokable via ADL.

Comments (2)

  1. Log in to comment