From f83a689909f1a16ce8a831180470c00e04f463e3 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 22 Oct 2026 17:48:22 +0200 Subject: [PATCH] Compare the token carry buffer's free space as a size_t variable clang-tidy's modernize-use-integer-sign-comparison (C++20) took the cast pointer difference for a signed operand. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/input/input_adapters.hpp | 3 ++- single_include/nlohmann/json.hpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index bc1340a02..05fd4c816 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -109,7 +109,8 @@ class token_carry_buffer void append(const char* first, const char* last) { const auto n = static_cast(last - first); - if (n > static_cast(m_capacity_end - m_end)) + const auto room = static_cast(m_capacity_end - m_end); + if (n > room) { grow(n); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index aea492e55..51661ab17 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -8574,7 +8574,8 @@ class token_carry_buffer void append(const char* first, const char* last) { const auto n = static_cast(last - first); - if (n > static_cast(m_capacity_end - m_end)) + const auto room = static_cast(m_capacity_end - m_end); + if (n > room) { grow(n); }