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


##########
cpp/src/arrow/array/data.cc:
##########
@@ -286,8 +286,10 @@ namespace {
 template <typename offset_type>
 BufferSpan OffsetsForScalar(uint8_t* scratch_space, offset_type value_size) {
   auto* offsets = reinterpret_cast<offset_type*>(scratch_space);
-  offsets[0] = 0;
-  offsets[1] = static_cast<offset_type>(value_size);
+  reinterpret_cast<std::atomic<offset_type>*>(&offsets[0])
+      ->store(0, std::memory_order_relaxed);
+  reinterpret_cast<std::atomic<offset_type>*>(&offsets[1])
+      ->store(static_cast<offset_type>(value_size), std::memory_order_relaxed);

Review Comment:
   You are right. The casts could be reduced. After a second thought, I think 
even with extra casts, the result would be wrong if the size of atomic is not 
the same as the payload. I tend to assume we are not going to support platforms 
that need a mutex for atomic 64. So I'll just reduce the casts. Thank you. 



-- 
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]

Reply via email to