I tried one example in msvc2022 and had a wrong return value in debug build, while GCC in compiler explorer was fine.
Shouldn't this function
template<awaitable A>
[[nodiscard]] decltype(auto) sync_await(A&& awaitable)
be declared like this
template<awaitable A>
[[nodiscard]] auto sync_await(A&& awaitable)
So no reference can be returned?
Of course, the whole path the return value takes could be reviewed where a reference is ok and where it should be passed by value.
And shouldn't the return value be properly synchronized, as the used std::binary_semaphore not necessarily synchronizes memory where the
return value might reside between threads ?
The x86 an x86-64 does not require memory fencing, but Arm might, I think.
Concurrency is hard and the total lack of warnings, static checks and support form compilers is offending.
I tried one example in msvc2022 and had a wrong return value in debug build, while GCC in compiler explorer was fine.
Shouldn't this function
be declared like this
So no reference can be returned?
Of course, the whole path the return value takes could be reviewed where a reference is ok and where it should be passed by value.
And shouldn't the return value be properly synchronized, as the used
std::binary_semaphorenot necessarily synchronizes memory where thereturn value might reside between threads ?
The x86 an x86-64 does not require memory fencing, but Arm might, I think.
Concurrency is hard and the total lack of warnings, static checks and support form compilers is offending.