[clang-tools-extra] FIX : bugprone-too-small-loop-variable - false-negative when const variable is used as loop bound (PR #81183)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 13:01:59 PST 2024


================
@@ -44,3 +44,5 @@ a larger user input.
     for (unsigned i = 0; i < size; ++i) {} // no warning with MagnitudeBitsUpperLimit = 31 on a system where unsigned is 32-bit
     for (int i = 0; i < size; ++i) {} // warning with MagnitudeBitsUpperLimit = 31 on a system where int is 32-bit
   }
+
+``-Wtautological-constant-out-of-range-compare`` compiler warning should also be used.
----------------
PiotrZSL wrote:

Not here, this is description to an MagnitudeBitsUpperLimit option, put this before it. And add info like:
"It's recommended to enable the compiler warning `-Wtautological-constant-out-of-range-compare` as well, since check does not inspect compile-time constant loop boundaries to avoid overlaps with the warning."

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


More information about the cfe-commits mailing list