Issue |
138842
|
Summary |
[clang-tidy] bugprone-infinite-loop false positive with structured binding
|
Labels |
clang-tidy,
false-positive
|
Assignees |
|
Reporter |
satorimarch
|
clang-tidy's `bugprone-infinite-loop` check incorrectly flags a valid loop as infinite when using a structured binding declaration in the loop condition.
Code example:
```cpp
#include <iostream>
int main()
{
int x = 10;
auto [y, _] = std::pair<int, int> {1, 2};
while (y < x) {
y++;
}
return 0;
}
```
Command:
```bash
./build/bin/clang-tidy temp.cpp -check=-*,bugprone-infinite-loop
```
Output:
```bash
temp.cpp:8:5: warning: this loop is infinite; none of its condition variables (x) are updated in the loop body [bugprone-infinite-loop]
8 | while (y < x) {
| ^
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs