[clang] [clang] Skip tautological comparison if the comparison involves the 'size_t' type (PR #74427)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 13 10:41:46 PST 2023


zygoloid wrote:

I don't think this type-based approach is the right choice. It will lead to a lot of false negatives, and I'm especially concerned that this patch is also dropping warnings for comparisons that just happen to be the same type as `size_t` (eg, direct use of `unsigned long` or `uint64_t`).

It would seem reasonable to suppress the warning for comparisons where one of the operands is specifically `sizeof(T)` (or a simple arithmetic computation involving `sizeof(T)` such as `sizeof(T) + k` or `k * sizeof(T)`).

https://github.com/llvm/llvm-project/pull/74427


More information about the cfe-commits mailing list