Skip to content

Misleading compile error for start_detached when not included #1921

@Zhang-JK

Description

@Zhang-JK

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions