From 1257917cda888af929d41d2e0d335901fe73acd0 Mon Sep 17 00:00:00 2001 From: emreyigit Date: Tue, 7 Apr 2026 16:24:09 +0300 Subject: [PATCH 1/3] Fix mis casting. --- hazelcast/src/hazelcast/client/client_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hazelcast/src/hazelcast/client/client_impl.cpp b/hazelcast/src/hazelcast/client/client_impl.cpp index 965593729..9759fd6ef 100644 --- a/hazelcast/src/hazelcast/client/client_impl.cpp +++ b/hazelcast/src/hazelcast/client/client_impl.cpp @@ -757,7 +757,7 @@ twos_complement(std::vector& a) } // add 1 int8_t carry = 1; - for (auto i = a.size() - 1; i >= 0; i--) { + for (int i = static_cast(a.size()) - 1; i >= 0; i--) { a[i] = a[i] + carry; if (a[i] == 0) { carry = 1; From 7c079d4cfb2a6781427c7dd41bc50ab3c1386c00 Mon Sep 17 00:00:00 2001 From: emreyigit Date: Mon, 20 Apr 2026 13:32:13 +0300 Subject: [PATCH 2/3] add tests --- hazelcast/test/src/HazelcastTests2.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hazelcast/test/src/HazelcastTests2.cpp b/hazelcast/test/src/HazelcastTests2.cpp index 186232bb2..48c638bf2 100644 --- a/hazelcast/test/src/HazelcastTests2.cpp +++ b/hazelcast/test/src/HazelcastTests2.cpp @@ -140,6 +140,22 @@ TEST_F(DecimalTest, cascading_carry_bit_test) { -67, 19, -58, 119, -111, -77, 0, 0, 0 }); } +TEST_F(DecimalTest, twos_complement_single_byte_full_carry) +{ + // carry propagates out of the only byte; the signed loop index must exit cleanly + std::vector v = { 0 }; + pimpl::twos_complement(v); + ASSERT_EQ((std::vector{ 0 }), v); +} + +TEST_F(DecimalTest, twos_complement_multi_byte_full_carry) +{ + // carry propagates out of every byte; a size_t loop index would wrap to SIZE_MAX + std::vector v = { 0, 0, 0 }; + pimpl::twos_complement(v); + ASSERT_EQ((std::vector{ 0, 0, 0 }), v); +} + class AddressHelperTest : public ClientTest {}; From a3977c131adea50bac4b7308df1dc2767df4b213 Mon Sep 17 00:00:00 2001 From: emreyigit Date: Mon, 20 Apr 2026 14:17:16 +0300 Subject: [PATCH 3/3] fix format --- hazelcast/test/src/HazelcastTests2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hazelcast/test/src/HazelcastTests2.cpp b/hazelcast/test/src/HazelcastTests2.cpp index 48c638bf2..1e704e0f8 100644 --- a/hazelcast/test/src/HazelcastTests2.cpp +++ b/hazelcast/test/src/HazelcastTests2.cpp @@ -142,7 +142,8 @@ TEST_F(DecimalTest, cascading_carry_bit_test) TEST_F(DecimalTest, twos_complement_single_byte_full_carry) { - // carry propagates out of the only byte; the signed loop index must exit cleanly + // carry propagates out of the only byte; the signed loop index must exit + // cleanly std::vector v = { 0 }; pimpl::twos_complement(v); ASSERT_EQ((std::vector{ 0 }), v); @@ -150,7 +151,8 @@ TEST_F(DecimalTest, twos_complement_single_byte_full_carry) TEST_F(DecimalTest, twos_complement_multi_byte_full_carry) { - // carry propagates out of every byte; a size_t loop index would wrap to SIZE_MAX + // carry propagates out of every byte; a size_t loop index would wrap to + // SIZE_MAX std::vector v = { 0, 0, 0 }; pimpl::twos_complement(v); ASSERT_EQ((std::vector{ 0, 0, 0 }), v);