-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 44618 |
| Resolution | FIXED |
| Resolved on | Jan 29, 2020 13:02 |
| Version | unspecified |
| OS | Linux |
| Blocks | #43900 |
| CC | @EugeneZelenko,@zmodem |
| Fixed by commit(s) | rG70f4c6e7b14f225f9628fbdab3620ce037613351 |
Extended Description
Hi,
The new bugprone-infinite-loop check is not detecting some easy patterns of finite loops, thus leading to false positives. Not sure if this can easily be fixed:
$ clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 10.0.175git
Optimized build.
Default target: x86_64-unknown-linux-gnu
Host CPU: broadwell
$ cat .clang-tidy
Checks: bugprone-infinite-loop
$ cat x.cpp
#include
int main(int /argc/, char** /argv/)
{
char foobar[] = "foobar";
char *pattern = foobar;
while (char c = *pattern) {
if (c == 'o') {
std::cout << "o" << std::endl;
}
++pattern;
}
return 0;
}
$ clang-tidy x.cpp
/home/d067158/x.cpp:7:5: warning: this loop is infinite; none of its condition variables (c) are updated in the loop body [clang-tidy-bugprone-infinite-loop]
while (char c = *pattern) {
^
$ ./x
o
o
Best regards
Dennis