From e563201f9e33f6d35e8b12de4ec7a1a36724087d Mon Sep 17 00:00:00 2001
From: Alex Richardson <arichardson@FreeBSD.org>
Date: Sun, 3 Mar 2024 22:22:07 -0800
Subject: cmList: Use ptrdiff_t for index_type

In commit 87fe031a07 (cmList class: various enhancements, 2023-04-26,
v3.27.0-rc1~142^2~1) this changed from `int` to `intptr_t`, but on some
systems (e.g. CHERI-enabled Arm or RISC-V), `intptr_t` is larger than 64
bits and using it for `index_type` here incurs an unnecessary
performance penalty.  Additionally, using `intptr_t` here results in an
ambiguous overload while calling `cmStrCat` with `intptr_t`: `error:
conversion from '__intcap' to 'const cmAlphaNum' is ambiguous`.

Instead of adding `intptr_t` overloads for `cmAlphaNum` for CHERI
systems, we can change the type to `ptrdiff_t` (which will be the same
as `intptr_t` on all other systems) and avoid carrying diffs that only
compile with a CHERI enabled compiler.
---
 Source/cmList.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Source/cmList.h b/Source/cmList.h
index c29aae7..e107096 100644
--- a/Source/cmList.h
+++ b/Source/cmList.h
@@ -6,7 +6,7 @@
 #include "cmConfigure.h" // IWYU pragma: keep
 
 #include <algorithm>
-#include <cstdint>
+#include <cstddef>
 #include <initializer_list>
 #include <iterator>
 #include <memory>
@@ -47,7 +47,7 @@ public:
 
   using value_type = container_type::value_type;
   using allocator_type = container_type::allocator_type;
-  using index_type = std::intptr_t;
+  using index_type = std::ptrdiff_t;
   using size_type = container_type::size_type;
   using difference_type = container_type::difference_type;
   using reference = container_type::reference;
-- 
cgit v0.12