bkietz commented on code in PR #40237:
URL: https://github.com/apache/arrow/pull/40237#discussion_r1561342145


##########
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:
   `FillScalarScratchSpaceHelper` doesn't need to write arbitrary arguments, 
and actually there's a risk of undefined behavior as written since you might 
`reinterpret_cast<int32_t*>(scratch_space + offset/*=1*/)`



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to