NVIDIA / NVIDIA/stdexec

Misleading compile error for start_detached when not included

Open
#1,921 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.4k
Forks
270
Avg merge
3d 6h
Merged PRs (30d)
39

Description

I am not sure if this is an issue that should be fixed
For the following code, im not including <exec/start_detached.hpp> for calling exec::start_detached:

#include <stdexec/execution.hpp>
// missing include file
// #include <exec/start_detached.hpp>

void do_some_work() {
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

int main() {
    auto work = stdexec::just() | stdexec::then([] {
        do_some_work();
    });

    exec::start_detached(std::move(work));

    std::this_thread::sleep_for(std::chrono::seconds(1));
    return 0;
}

and the compiler gives error:

-> % g++ ./include-issue.cpp -I/some/random/path/stdexec/include -std=c++20 -ltbb
./include-issue.cpp: In function ‘int main()’:
./include-issue.cpp:14:25: error: no match for call to ‘(const experimental::execution::start_detached_t) (std::remove_reference<stdexec::{anonymous}::__sexpr<<lambda closure object>stdexec::<lambda()>()>&>::type)’
   14 |     exec::start_detached(std::move(work));
      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
  1. it's a bit misleading the compiler reporting "no match call" instead of "not defined", there might be a forward declarations seen by compiler
  2. given that im only including files under stdexec, seeing forward declarations from exec might not be an expected behavior?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the diagnostic with include-issue.cpp using g++ in C++20 mode and the shown stdexec/execution.hpp include. Compare the declarations exposed by stdexec/execution.hpp with exec/start_detached.hpp and determine whether the reported error or header visibility is unintended; done means the expected include behavior and diagnostic are covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.