| Issue |
208693
|
| Summary |
[clang-tidy] readability-use-std-min-max generates invalid code, where bare `size_type` is used
|
| Labels |
|
| Assignees |
|
| Reporter |
e-kwsm
|
clang-tidy 22.1.8
```cpp
#include <string>
void f(const std::string &s, unsigned &n) {
if (s.size() > n)
n = s.size();
}
```
`clang-tidy --checks=readability-use-std-min-max --fix a.cpp` rewrites the function body as follows
```cpp
n = std::max<size_type>(s.size(), n);
```
which does not compile since `size_type` is unknown; the correct fix is
```cpp
n = std::max<decltype(s.size())>(s.size(), n);
// or std::string::size_type, or size_t?
```
<https://godbolt.org/z/4oYsddq6d>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs