| Issue |
172018
|
| Summary |
False positve bugprone-use-after-move when object is modified in lambda
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
chrchr-github
|
~~~c++
#include <string>
#include <iostream>
void h(std::string x) { std::cout << x << '\n'; }
int main() {
std::string s;
char c = 'A';
auto g = [&]() {
if (c <= 'Z') {
s = std::string(100, c);
++c;
return true;
}
return false;
};
while (g()) {
if (!s.empty()) {
h(std::move(s));
}
}
}
~~~
~~~
<source>:18:14: warning: 's' used after it was moved [bugprone-use-after-move]
18 | if (!s.empty()) {
| ^
<source>:19:15: note: move occurred here
19 | h(std::move(s));
| ^
<source>:18:14: note: the use happens in a later loop iteration than the move
18 | if (!s.empty()) {
| ^
1 warning generated.
~~~
https://godbolt.org/z/YhYjvKP6z
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs