clang-tidy warns about use-after-move inside REQUIRE
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
https://www.godbolt.org/z/1xsofWzfj - `REQUIRE` with a `std::move`, like `REQUIRE(std::move(x) == std::move(y))` triggers clang-tidy. I am not sure if I should report this to clang-tidy as a false positive.
```cpp
TEST_CASE("double move")
{
std::vector vec{1, 2, 3};
REQUIRE(std::move(vec).size() == 3);
}
```
triggers
```
[:9:23: warning: 'vec' used after it was moved [bugprone-use-after-move,hicpp-invalid-access-moved]](javascript:;)
REQUIRE(std::move(vec).size() == 3);
^
[:9:28: note: move occurred here](javascript:;)
REQUIRE(std::move(vec).size() == 3);
^
[:9:23: note: the use happens in a later loop iteration than the move](javascript:;)
REQUIRE(std::move(vec).size() == 3);
^
94343 warnings generated.
Suppressed 94346 warnings (94341 in non-user code, 5 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
Catch 2.11.0 does not trigger clang-tidy but 2.12.1 does.
**Expected behavior**
No warnings from clang-tidy about use-after-move
**Reference**
b7b346c3e56030d19ac58d33326b69bbaf226552 adds a
```cpp
/* The expression should not be evaluated, but warnings should hopefully be checked */ \
CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \
// some code ...
catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
```
Perhaps listing `__VA_ARGS__` twice trips clang-tidy?
Contributor guide
Assessment
This issue has not been assessed yet.