From ba16e7cb08d8b21a3dbf62af722e869affda29f4 Mon Sep 17 00:00:00 2001 From: mwish Date: Tue, 24 Nov 2026 23:04:10 +0800 Subject: [PATCH] util: making SafeCopy call std::bit_cast and avoid gcc's LAUNDER --- cpp/src/arrow/util/ubsan.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cpp/src/arrow/util/ubsan.h b/cpp/src/arrow/util/ubsan.h index 6c8a9812af29..ac2ac55df179 100644 --- a/cpp/src/arrow/util/ubsan.h +++ b/cpp/src/arrow/util/ubsan.h @@ -19,6 +19,7 @@ #pragma once +#include #include #include #include @@ -82,11 +83,7 @@ ARROW_FORCE_INLINE U> SafeCopy(T value) { using TypeU = std::remove_const_t; - arrow::internal::AlignedStorage raw_data; - std::memcpy(raw_data.get(), static_cast(&value), sizeof(T)); - auto data = *raw_data.get(); - raw_data.destroy(); - return data; + return std::bit_cast(value); } template