cplusplus / sender-receiver

Issues list for P2300
Apache License 2.0
20 stars 3 forks source link

error types should be nothrow-movable #115

Open ericniebler opened 10 months ago

ericniebler commented 10 months ago

Issue by lucteo Sunday Nov 28, 2021 at 17:08 GMT Originally opened as https://github.com/NVIDIA/stdexec/issues/284


Given:

This seems confusing.

The only way that set_error() can throw inside the operation state is when the error type throws on move. If the E type can throw while being moved, then:

Again, the receiver connected to the operation state of let_error() doesn't allow set_error(E) to throw

Wouldn't it be better for the paper to specify that all error types are nothow-movable? The paper has this requirement in several places for other types. Adding this specification will make the implementation simpler and more coherent.

ericniebler commented 10 months ago

Comment by lucteo Sunday Nov 28, 2021 at 17:34 GMT


Looking at the libunifex implementation (https://github.com/facebookexperimental/libunifex/blob/2547d87fb98a1fe70eccc170a8c91b144648517d/include/unifex/receiver_concepts.hpp), if the error type throws on move, then the program is ill formed. The set_error() CPO is defined as noexcept, it doesn't constrain the error type to not throw, and allows the move constructor to be called on the given error.

Thus, the inner call to tag_invoke may throw, without try/catch, inside a noexcept function.

lewissbaker commented 3 months ago

We should discuss about having this restriction in the set_error() CPO. i.e. that it mandates that the error type must be nothrow move-constructible.