From 032a011803d217f38c1392b9812db347ad4875fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Tudor=20TOPAL=C4=82=20=28101668=29?= Date: Thu, 22 Jun 2023 20:36:43 +0300 Subject: [PATCH] ICU-22419 Fix memory alignment for UTF-16 encoding --- icu4c/source/i18n/rulebasedcollator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/icu4c/source/i18n/rulebasedcollator.cpp b/icu4c/source/i18n/rulebasedcollator.cpp index 41bd3a74e23a..67854e402deb 100644 --- a/icu4c/source/i18n/rulebasedcollator.cpp +++ b/icu4c/source/i18n/rulebasedcollator.cpp @@ -989,21 +989,21 @@ RuleBasedCollator::doCompare(const char16_t *left, int32_t leftLength, } else { if ((uint32_t)leftLength >= sizeof(uint64_t) && (uint32_t)rightLength >= sizeof(uint64_t) - && (uintptr_t)left % sizeof(uint64_t) == (uintptr_t)right % sizeof(uint64_t)) { + && (uintptr_t)(const void*)left % sizeof(uint64_t) == (uintptr_t)(const void*)right % sizeof(uint64_t)) { int32_t i = 0; int32_t limit = leftLength < rightLength ? leftLength : rightLength; // Memory alignment step. while(i < limit && left[i] == right[i] - && (uintptr_t)(left + i) % sizeof(uint64_t) != 0) { + && ((uintptr_t)(const void*)(left + i)) % sizeof(uint64_t) != 0) { ++i; } equalPrefixLength += i; // Double word baesd comparison. - if (i < limit && (uintptr_t)(left + i) % sizeof(uint64_t) == 0) { - const uint64_t *dWordLeft = (const uint64_t *)left; - const uint64_t *dWordRight = (const uint64_t *)right; + if (i < limit && (uintptr_t)(const void*)(left + i) % sizeof(uint64_t) == 0) { + const uint64_t *dWordLeft = (const uint64_t *)(const void *)left; + const uint64_t *dWordRight = (const uint64_t *)(const void *)right; int32_t dWordLength = (leftLength < rightLength ? leftLength : rightLength) / sizeof(uint64_t); i = 0;