<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [clang-analyzer] False report about moved-from object with coroutines"
href="https://bugs.llvm.org/show_bug.cgi?id=48541">48541</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[clang-analyzer] False report about moved-from object with coroutines
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dmitry.polukhin@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Minimal reproducer is a bit long due to coroutine boilerplate
<a href="https://godbolt.org/z/P3P6ax">https://godbolt.org/z/P3P6ax</a>:
#include <string>
namespace std {
namespace experimental {
template <class Ret, typename... T>
struct coroutine_traits { using promise_type = typename Ret::promise_type; };
template <class Promise = void>
struct coroutine_handle {
static coroutine_handle from_address(void *) noexcept;
};
template <>
struct coroutine_handle<void> {
template <class PromiseType>
coroutine_handle(coroutine_handle<PromiseType>) noexcept;
static coroutine_handle from_address(void *);
};
struct suspend_always {
bool await_ready() noexcept { return false; }
void await_suspend(coroutine_handle<>) noexcept {}
void await_resume() noexcept {}
};
struct suspend_never {
bool await_ready() { return true; }
void await_suspend(coroutine_handle<>) {}
void await_resume() {}
};
} // namespace experimental
} // namespace std
namespace folly {
namespace coro {
using std::experimental::suspend_always;
using std::experimental::suspend_never;
using std::experimental::coroutine_handle;
template<class T>
struct Task {
struct promise_type {
Task<T> get_return_object();
suspend_always initial_suspend();
suspend_always final_suspend() noexcept;
void return_value(T);
void unhandled_exception();
auto yield_value(Task<T>) { return final_suspend(); }
};
bool await_ready() { return false; }
void await_suspend(coroutine_handle<>) {}
T await_resume();
};
template<>
struct Task<void> {
struct promise_type {
Task<void> get_return_object();
suspend_always initial_suspend();
suspend_always final_suspend();
void return_void();
void unhandled_exception();
auto yield_value(Task<void>) { return final_suspend(); }
};
bool await_ready() { return false; }
void await_suspend(coroutine_handle<>) {}
void await_resume() {}
};
}} // namespace folly::coro
folly::coro::Task<std::string> foo() {
std::string operationsMap;
co_return operationsMap;
}
Command line options: -std=c++17 -fcoroutines-ts
<source>:76:13: warning: Moved-from object 'operationsMap' of type
'std::basic_string' is moved [clang-analyzer-cplusplus.Move]
co_return operationsMap;
^
<source>:76:13: note: Object 'operationsMap' of type 'std::basic_string' is
left in a valid but unspecified state after move
<source>:76:13: note: Moved-from object 'operationsMap' of type
'std::basic_string' is moved
1 warning generated.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>