[coroutine] Clang gives incorrect warnings
debashish-ghosh opened this issue · 4 comments
debashish-ghosh commented
In the following code snippet:
#include <coroutine>
struct coro {
struct promise_type {
coro get_return_object();
constexpr auto initial_suspend() { return std::suspend_never{}; }
constexpr auto final_suspend() noexcept { return std::suspend_always{}; }
void unhandled_exception();
void return_void();
};
};
coro c(int i) {
co_await (i = 0, std::suspend_always{});
}
clang gives a weird warning:
warning: multiple unsequenced modifications to 'i' [-Wunsequenced]
co_await (i = 1, std::suspend_always());
^
1 warning generated.
Another example can be found here.
ecatmur commented
It looks like this is caused by https://reviews.llvm.org/D115187 df2a4ea
the fix will be to skip CoroutineSuspendExpr
in SemaChecking/CheckUnsequencedOperations, like we do in AnalyzeImplicitConversions.
r-barnes commented
We observe what we think is the same issue when doing, eg,
co_await foo(attempts++)
bcardosolopes commented
A patch is up in https://reviews.llvm.org/D142077
bcardosolopes commented