Skip to content

Commit 450caf2

Browse files
rokraulcd
authored andcommitted
GH-35143: [R][C++] Fixed shape tensor causes broken build on OSX (#35154)
### Rationale for this change `std::reinterpret_pointer_cast` was introduced with FixedShapeTensor PR (#34797) but is not available on OSX (see #35143). ### What changes are included in this PR? This change switches to using `internal::checked_pointer_cast`. ### Are these changes tested? Change is tested in CI, but should also be verified on crossbow. ### Are there any user-facing changes? No. * Closes: #35143 Authored-by: Rok Mihevc <rok@mihevc.org> Signed-off-by: Dewey Dunnington <dewey@voltrondata.com>
1 parent 6e80cbb commit 450caf2

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

cpp/src/arrow/extension/fixed_shape_tensor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ Result<std::shared_ptr<FixedShapeTensorArray>> FixedShapeTensorArray::FromTensor
268268
ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Array> arr,
269269
FixedSizeListArray::FromArrays(value_array, cell_size));
270270
std::shared_ptr<Array> ext_arr = ExtensionType::WrapArray(ext_type, arr);
271-
return std::reinterpret_pointer_cast<FixedShapeTensorArray>(ext_arr);
271+
return std::static_pointer_cast<FixedShapeTensorArray>(ext_arr);
272272
}
273273

274274
const Result<std::shared_ptr<Tensor>> FixedShapeTensorArray::ToTensor() const {
275275
// To convert an array of n dimensional tensors to a n+1 dimensional tensor we
276276
// interpret the array's length as the first dimension the new tensor.
277277

278-
auto ext_arr = internal::checked_pointer_cast<FixedSizeListArray>(this->storage());
278+
auto ext_arr = std::static_pointer_cast<FixedSizeListArray>(this->storage());
279279
auto ext_type = internal::checked_pointer_cast<FixedShapeTensorType>(this->type());
280280
ARROW_RETURN_IF(!is_fixed_width(*ext_arr->value_type()),
281281
Status::Invalid(ext_arr->value_type()->ToString(),

cpp/src/arrow/extension/fixed_shape_tensor_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ TEST_F(TestExtensionType, CreateExtensionType) {
101101
ASSERT_EQ(ext_type_->Serialize(), serialized_);
102102
ASSERT_OK_AND_ASSIGN(auto ds,
103103
ext_type_->Deserialize(ext_type_->storage_type(), serialized_));
104-
auto deserialized = std::reinterpret_pointer_cast<ExtensionType>(ds);
104+
auto deserialized = internal::checked_pointer_cast<ExtensionType>(ds);
105105
ASSERT_TRUE(deserialized->Equals(*ext_type_));
106106

107107
// Test FixedShapeTensorType methods
@@ -267,7 +267,7 @@ TEST_F(TestExtensionType, CreateFromTensor) {
267267

268268
ASSERT_OK_AND_ASSIGN(auto fsla_arr,
269269
FixedSizeListArray::FromArrays(arr, fixed_size_list(binary(), 2)));
270-
auto ext_arr_5 = std::reinterpret_pointer_cast<FixedShapeTensorArray>(
270+
auto ext_arr_5 = std::static_pointer_cast<FixedShapeTensorArray>(
271271
ExtensionType::WrapArray(ext_type_5, fsla_arr));
272272
EXPECT_RAISES_WITH_MESSAGE_THAT(
273273
Invalid, testing::HasSubstr("binary is not valid data type for a tensor"),

0 commit comments

Comments
 (0)