bkietz commented on code in PR #40237:
URL: https://github.com/apache/arrow/pull/40237#discussion_r1576515068
##########
cpp/src/arrow/scalar.cc:
##########
@@ -542,6 +542,21 @@ struct ScalarValidateImpl {
}
};
+template <size_t offset, typename T, typename... Args>
+void FillScalarScratchSpaceHelper(uint8_t* scratch_space, T first, Args...
args) {
+ static_assert(offset + sizeof(T) <= internal::kScalarScratchSpaceSize);
+ *reinterpret_cast<T*>(scratch_space + offset) = first;
+ if constexpr (sizeof...(args) > 0) {
+ FillScalarScratchSpaceHelper<offset + sizeof(T)>(scratch_space,
+
std::forward<Args>(args)...);
+ }
+}
+
+template <typename... Args>
+void FillScalarScratchSpace(Args... args) {
+ FillScalarScratchSpaceHelper<0>(std::forward<Args>(args)...);
+}
+
Review Comment:
The UB I'm referring to is violation of fundamental alignment requirements
[(basic.align#1)](https://timsong-cpp.github.io/cppwp/n4659/basic.align#1):
`int32_t` can only be allocated on a four byte boundary and it is known at
compile time that `reinterpret_cast<int32_t*>(scratch_space + offset/*=1*/)` is
not so aligned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]