| Issue |
171193
|
| Summary |
[clang-tidy] false positive and invalid fix for readability-container-size-empty with regex
|
| Labels |
clang-tidy,
false-positive
|
| Assignees |
|
| Reporter |
sadan4
|
given the following code
```cpp
#include <regex>
void foo() {
std::smatch match;
if (match.length());
}
```
clang-tidy will suggest to replace `match.length()` with `!match.empty()`; however, this is invalid because for successful matches of zero length, `match.length() == 0` and `match.empty() == false`.
godbolt sample demonstrating clang-tidy's incorrect diagnostic https://godbolt.org/z/qnzc4Pcrc
godbolt sample demonstrating a zero length match (execute the code) https://godbolt.org/z/YvT7hb4f4
regex 101 sample demonstrating a zero length regex & match https://regex101.com/r/dzUrRp/1
Related: https://github.com/llvm/llvm-project/issues/88203
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs