Open bernardosulzbach opened 1 month ago
@llvm/issue-subscribers-clang-static-analyzer
Author: Bernardo Sulzbach (bernardosulzbach)
Without std::views
:
#include <array>
int main() {
std::array<std::pair<int, int>, 4> a = {};
for (auto [x, y] : a) {
auto f = [&]() { return 2 * x ; };
f();
}
}
This is clean though:
int main() {
struct { int i, j; } a[1] = {};
for (auto [x, y] : a) {
auto f = [&]() { return 2 * x ; };
f();
}
}
So the warning seems to be related to std::pair
.
Its probably caused by the structured binding. I know there are a few tickets already for that.
https://github.com/llvm/llvm-project/issues/91835 looks similar.
Output
Maybe it needs
std::views::enumerate
to reproduce?Version
g++ (SUSE Linux) 13.3.0 clang-tidy version 18.1.8
Inputs
I tried to minify the real source code, but you can probably minify it further and still reproduce.
C++
CMake