NVIDIA / NVIDIA/stdexec

`exec::finally()` shouldn't include `std::exception_ptr` in the error types if neither the source or final senders include that error type

Open
#1,335 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I would have expected the following code to compile, but it fails because let_error tries to instantiate a call to the lambda with an argument of type std::exception_ptr.

https://godbolt.org/z/PK8YjohW8

#include <stdexec/execution.hpp>
#include <exec/finally.hpp>

#include <cstdio>

struct X {
    X() : value(0) { std::puts("X::X()"); }
    X(X&& o) noexcept : value(o.value) { std::puts("X::X(X&&)"); }
    X(const X& o) noexcept : value(o.value)  { std::puts("X::X(const X&)"); }
    ~X() { std::puts("X::~X()"); value = -1; }
    int value;
};

int main() {
    auto result = stdexec::sync_wait(
        stdexec::let_error(
            exec::finally(
                stdexec::just_error(X{}),
                stdexec::just()),
            [](const X& x) noexcept {
                std::printf("caught X(value=%i)\n", x.value);
                return stdexec::just();
            }));
}

I suspect that this is because we don't know ahead of time whether connect() is potentially throwing.
We could potentially work around this by instead connecting the final-sender at connect-time of the finally sender. This way, we know that we will be able start the final-operation when the input operation completes regardless of whether the connect() method is throwing or not.

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

Start with the reproducer linked in the issue and inspect exec/finally.hpp together with the sender and error-type handling in stdexec/execution.hpp. Trace why let_error is instantiated with std::exception_ptr when neither sender declares it. Done means the example compiles without that extra error type while preserving finally behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.