summaryrefslogtreecommitdiffstats
path: root/Source/cmList.h
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2024-03-04 06:22:07 (GMT)
committerBrad King <brad.king@kitware.com>2024-03-08 14:49:03 (GMT)
commite563201f9e33f6d35e8b12de4ec7a1a36724087d (patch)
treec57a6add1322cc7f30e16e019e0d871b1901a2a6 /Source/cmList.h
parentdebf777290433e5aa074cb5e51fa12c46598f829 (diff)
downloadCMake-e563201f9e33f6d35e8b12de4ec7a1a36724087d.zip
CMake-e563201f9e33f6d35e8b12de4ec7a1a36724087d.tar.gz
CMake-e563201f9e33f6d35e8b12de4ec7a1a36724087d.tar.bz2
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.
Diffstat (limited to 'Source/cmList.h')
-rw-r--r--Source/cmList.h4
1 files 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;