facebookexperimental / facebookexperimental/libunifex
An unused `async_scope` can't be destroyed
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Description
Creating and destroying a `unifex::v2::async_scope` without using it for anything results in an assertion failure:
```
Assertion failed: join_started(), file unifex/v2/async_scope.hpp, line 90
```
This can come up if the scope is a member of a class, and another member's constructor throws, e.g.:
```c++
class C {
unifex::async_scope scope;
TypeWhoseConstructorThrows m;
};
```
Is this the intended behavior?
It's understandable that one doesn't want to special-case the destructor's contract, but on the other hand it is quite odd not to be able to destroy a default-constructed object.
I'm not really sure if this can be easily worked around though without overhead for release builds. Maybe the scope could start in some kind of special state (say, `std::size_t(-1)`) and transition out of it in `try_record_start()`, but guarded by `#ifndef NDEBUG`?
Contributor guide
Assessment
This issue has not been assessed yet.