<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57758>57758</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy 14.0.6 gives a false-positive bugprone-use-after-move report in chained expressions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
georgthegreat
</td>
</tr>
</table>
<pre>
Consider the following code
```
#include <cassert>
#include <vector>
struct test {
test& foo(std::vector<int> const& v) { assert(v.size() == 1); return *this; }
int bar(std::vector<int> v ) { return v.size(); }
};
int main() {
std::vector<int> v = { 42 };
return test{}.foo(v).bar(std::move(v));
}
```
clang-tidy 14.0.6 reports the following error:
```
tidy14-bug/main.cpp:11:23: error: 'v' used after it was moved [bugprone-use-after-move,-warnings-as-errors]
return test{}.foo(v).bar(std::move(v));
^
tidy14-bug/main.cpp:11:30: note: move occurred here
return test{}.foo(v).bar(std::move(v));
^
tidy14-bug/main.cpp:11:23: note: the use and move are unsequenced, i.e. there is no guarantee about the order in which they are evaluated
return test{}.foo(v).bar(std::move(v));
^
```
The standard, however, clearly [defines the behavior](http://eel.is/c++draft/expr.call#8) for the current case.
This false-positive breaks a lot of code in our codebase.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9Ve2SmyAUfRr8w-goJpr88Ec-tk_QF0C8Ki0LKaBp-vS9YLKbTXd22pnOOgwCF84993C9tqa7NAejnezAUj8C7Y1S5iz1QIXpgORHku9IlV_bMmWl1EJNHVBSHgR3Dqwn5dN71hmEN_bVGHvn7SQ89eA8JfV-WYxTwipkYAjbON-RcofthnCQOjhBWnrZNxO2DcfplQDbzJmTvwAH0VIesdECx6TcUwt-spoStvOjdGGF1MerZ0SmLbcfeZ3pzdsV6N7XG7QwKPf34Qb4Zy71jdhLxPh85BDZB4crRu8xw6krh6gYotXHbBEtSJI9RPJsZriaFqr31F5ZP1xx7IXieki97C60WGV5VqHjk7HePWQKWBuo794gvwUMIMUqbaeBsC9BjEycTnikKLBjJXYvKKh0jWxrOjnoKO89Zqb09MwdDbF0lKz3iHOyRkOKe9K4JV3iPKRnbjWScil3aYR0ZH38r9LRdx-yfvqLUMs8RKiNh_AODqgRYrIW4xrBwicQ_Se-y9Xc-IZrR8Up193CnVtc0A5-TKAFdKg_lRlkYSNapMOTdJi45doD7m7N5COIsaHeSE3PoxRjWLpELJi5mrhHpE-8sHdz_yuydB4D5TaGNZozzGDDUCjgVl1CHnbQSw3L99DCyGeJKYzpxjaj90FElBQbgMqw6LAvgrA9ts5izob1nyebCa4UFs1YG3qzVOGYEVg2sLhCdiOEcvZcYcKfjJNeovytBf7dUU6V8dT0sWQHVc1k47gNxxNoiqoqWVlXa5Z0Tdltyy1PvPQKmj8_8QGBA-Sjq_e_uGtFCE7FiLmDaRyCAuck1ulksqoJSrgXKQbpx6nNhHnGiVLz7ZUi-jesgTiVzk0Q1FrX9XqTjA2r8q7argqAoufltq-LvNoWa5bXotj2eZso3oJyDV4Iip_IhuWM5bijyFldsqztN6IC2PTrvO2hArLKARNdZcFxZuyQ2CZywCAdGpV03r0a8f8iBw1ww-eTH41tBkAjXtaAl-CTSLqJjH8DjhYqFw">