Issue 129570
Summary [Clang] Should we warn on more chained comparisons?
Labels clang:frontend, clang:diagnostics
Assignees
Reporter Sirraide
    #128145 made chained comparisons an error by default, and both there and in #129069, we’ve been having a discussion that there might be other cases that we might want to warn about too; since #129069 is also concerned with the wording of the diagnostic, I’m opening a new issue just for the former.

Currently, the question is what to do with cases such as:
```c++
void f(int a, int b, bool c) {
    if (a < b == c) { /* ... */ }
}
```
This is sound because we’re comparing two `bool`s with `==` here, but if we change the type of `c` to something other than `bool`, then this becomes more questionable. We might want to do something about this case as well (it is worth noting that clang-tidy already warns about this). Currently, we only diagnose chained `<`/`>`/`<=`/`>=`.

See also https://github.com/llvm/llvm-project/issues/129069#issuecomment-2693937679
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to