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

runLambda needs to explicitly return void #2091

Closed
nlslatt opened this issue Feb 14, 2023 · 2 comments · Fixed by #2106
Closed

runLambda needs to explicitly return void #2091

nlslatt opened this issue Feb 14, 2023 · 2 comments · Fixed by #2106
Assignees

Comments

@nlslatt
Copy link
Collaborator

nlslatt commented Feb 14, 2023

Describe the bug
The ARM Intel compiler on Gitlab CI emits this warning:

/.../vt/src/vt/runnable/runnable.h(245): warning #1011: missing return statement at end of non-void function "vt::runnable::RunnableNew::runLambda(Callable &&, Args &&...) [with Callable=bool (NodeObj::*)(), Args=<NodeObj *>]"

about this code from runnable/runnable.h:

  /**
   * \brief Run the task as a lambda!
   */
  template <typename Callable, typename... Args>
  decltype(auto) runLambda(Callable&& c, Args&&... args) {
    start();
    if constexpr(std::is_void_v<std::invoke_result_t<Callable, Args...>>) {
      std::invoke(std::forward<Callable>(c), std::forward<Args>(args)...);
      finish();
    } else {
      decltype(auto) r{std::invoke(std::forward<Callable>(c), std::forward<Args>(args)...)};
      finish();
      return r;
    }
  }

We probably just need to explicitly return; for the case where the lambda returns void.

@PhilMiller
Copy link
Member

If adding return; doesn't fix things, we could potentially rework this to something like

  template <typename Callable, typename... Args>
  decltype(auto) runLambda(Callable&& c, Args&&... args) {
    start();

    // Arrange a scope guard to call finish() without any sort of dynamic allocation
    struct finisher {
       Runnable *r;
       ~finisher() { r->finish(); }
    };
    finisher f(this);

    return std::invoke(std::forward<Callable>(c), std::forward<Args>(args)...);
  }

@cz4rs
Copy link
Contributor

cz4rs commented Mar 14, 2023

The same warning is visible in nvcc output (#2104).

@cz4rs cz4rs self-assigned this Mar 14, 2023
cz4rs added a commit that referenced this issue Mar 14, 2023
cz4rs added a commit that referenced this issue Mar 15, 2023
cz4rs added a commit that referenced this issue Mar 15, 2023
cz4rs added a commit that referenced this issue Mar 15, 2023
lifflander pushed a commit that referenced this issue Mar 21, 2023
cz4rs added a commit that referenced this issue Mar 27, 2023
cz4rs added a commit that referenced this issue Mar 27, 2023
cz4rs added a commit that referenced this issue Mar 30, 2023
cz4rs added a commit that referenced this issue Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants