Issue 136105
Summary [clang-tidy] False positive bugprone-use-after-move with std::tie
Labels clang-tidy, false-positive
Assignees
Reporter dmpolukhin
    Minimal reproducer https://godbolt.org/z/PoboWj4PM:
```c++
#include <tuple>
#include <utility>
#include <string>

std::pair<std::string, std::string> foo(std::string a, std::string b) {
  return std::make_pair(std::move(a), std::move(b));
}

void bar(std::string a, std::string b) {
  std::tie(a, b) = foo(std::move(a), std::move(b));
 std::tie(a, b) = foo(std::move(a), std::move(b));
}

/**
test.cpp:11:34: warning: 'a' used after it was moved [bugprone-use-after-move]
   11 | std::tie(a, b) = foo(std::move(a), std::move(b));
      | ^
test.cpp:10:24: note: move occurred here
   10 | std::tie(a, b) = foo(std::move(a), std::move(b));
      | ^
test.cpp:11:48: warning: 'b' used after it was moved [bugprone-use-after-move]
   11 |   std::tie(a, b) = foo(std::move(a), std::move(b));
      | ^
test.cpp:10:38: note: move occurred here
   10 |   std::tie(a, b) = foo(std::move(a), std::move(b));
      | ^
**/
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to