Skip to content

Commit

Permalink
apacheGH-38090: [C++][Emscripten] compare: Suppress shorten-64-to-32 …
Browse files Browse the repository at this point in the history
…warnings

We need explicit cast to use `int64_t` for `size_t` on Emscripten.

Explicit casts.
  • Loading branch information
kou committed Oct 6, 2023
1 parent 3697bcd commit c224401
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cpp/src/arrow/compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class RangeDataEqualsImpl {
auto compare_runs = [&](int64_t i, int64_t length) -> bool {
return memcmp(left_data + (left_start_idx_ + left_.offset + i) * byte_width,
right_data + (right_start_idx_ + right_.offset + i) * byte_width,
length * byte_width) == 0;
static_cast<size_t>(length * byte_width)) == 0;
};
VisitValidRuns(compare_runs);
} else {
Expand Down Expand Up @@ -415,7 +415,8 @@ class RangeDataEqualsImpl {
const CType* right_values = right_.GetValues<CType>(1);
VisitValidRuns([&](int64_t i, int64_t length) {
return memcmp(left_values + left_start_idx_ + i,
right_values + right_start_idx_ + i, length * sizeof(CType)) == 0;
right_values + right_start_idx_ + i,
static_cast<size_t>(length) * sizeof(CType)) == 0;
});
return Status::OK();
}
Expand Down Expand Up @@ -445,7 +446,8 @@ class RangeDataEqualsImpl {
if (left_data != nullptr && right_data != nullptr) {
const auto compare_ranges = [&](int64_t left_offset, int64_t right_offset,
int64_t length) -> bool {
return memcmp(left_data + left_offset, right_data + right_offset, length) == 0;
return memcmp(left_data + left_offset, right_data + right_offset,
static_cast<size_t>(length)) == 0;
};
CompareWithOffsets<typename TypeClass::offset_type>(1, compare_ranges);
} else {
Expand Down

0 comments on commit c224401

Please sign in to comment.