You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++] util: making SafeCopy call c++20's std::bit_cast #55763
arrow::util::SafeCopy was originally added before Arrow adopted C++20. In #48429, it was changed to go through arrow::internal::AlignedStorage, whose get() calls arrow::internal::launder (std::launder).
In GCC (both x86_64 and AArch64, e.g., GCC 14.2 with -O3 -std=c++20), std::launder lowers to .LAUNDER(&raw_data.data_) which GCC treats as clobbering memory (missed: statement clobbers memory: _21 = .LAUNDER (&raw_data.data_);). This blocks loop auto-vectorization in hot loops using SafeCopy (for example, ALP decoding in alp_compression.cc).
Since Arrow now requires C++20 and SafeCopy's constraints (std::is_trivially_copyable_v<T> && std::is_trivially_copyable_v<U> && sizeof(T) == sizeof(U)) match std::bit_cast (which also natively supports non-default-constructible types), we can implement SafeCopy directly with std::bit_cast<std::remove_const_t<U>>(value).
Activity