Issue 108022
Summary [clang-tidy] False negative readability-use-std-min-max for integers and less-than/greater-than comparison
Labels clang-tidy
Assignees
Reporter chrchr-github
    ~~~c++
int f(int i) {
    if (i <= 0) // FN
        i = 1;
    return i;
}
int g(int i) {
    if (i < 1) // warning
        i = 1;
 return i;
}
~~~
~~~
<source>:7:5: warning: use `std::max` instead of `<` [readability-use-std-min-max]
    1 | int f(int i) {
 2 |     if (i <= 0) // FN
    3 |         i = 1;
    4 |     return i;
    5 | }
    6 | int g(int i) {
    7 |     if (i < 1) // warning
      |     ^~~~~~~~~~~~~~~~~~~~~
      |     i = std::max(i, 1);
    8 |         i = 1;
      |         ~~~~~~
~~~
The two functions are equivalent, but there is only one warning.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to