[clang] [clang-format] Fix comparison warning in 32-bit builds (PR #172627)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 17 03:22:54 PST 2025


================
@@ -642,7 +642,9 @@ class LineJoiner {
         return 0;
       const auto N = MergedLines + LinesToBeMerged;
       // Check if there is even a line after the inner result.
-      if (std::distance(I, E) <= N)
+      auto Distance = std::distance(I, E);
+      assert(Distance >= 0);
+      if (static_cast<decltype(N)>(Distance) <= N)
----------------
HazardyKnusperkeks wrote:

```suggestion
      if (auto Distance = std::distance(I, E); static_cast<decltype(N)>(Distance) <= N)
```
Don't need the assert.
Or use `std::cmp_less_equal`.

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


More information about the cfe-commits mailing list