Issue |
143121
|
Summary |
overzealous `-Wconditional-uninitialized` with known state of conditional code
|
Labels |
clang:diagnostics,
false-positive
|
Assignees |
|
Reporter |
firewave
|
```
#include <string>
#include <vector>
int func(const char*);
extern void f(const std::string &file);
void f(const std::string &file)
{
const std::vector<std::string> filenames = {file};
int err;
for (const std::string & f : filenames) {
err = func(f.c_str());
if (err == 0) {
break;
}
}
if (err != 0) {}
}
```
```
<source>:18:9: warning: variable 'err' may be uninitialized when used here [-Wconditional-uninitialized]
18 | if (err != 0) {}
| ^~~
<source>:11:12: note: initialize the variable 'err' to silence this warning
11 | int err;
| ^
| = 0
```
https://godbolt.org/z/6ET1dnvYf
`filenames` is always non-empty so `err` will always be assigned and is never not initialized.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs