-
Notifications
You must be signed in to change notification settings - Fork 16k
Open
Labels
Description
#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.
Reactions are currently unavailable