emkornfield commented on a change in pull request #10627:
URL: https://github.com/apache/arrow/pull/10627#discussion_r665490308
##########
File path: cpp/src/arrow/util/bit_stream_utils.h
##########
@@ -418,14 +450,65 @@ inline bool BitReader::GetVlqInt(uint32_t* v) {
}
inline bool BitWriter::PutZigZagVlqInt(int32_t v) {
- auto u_v = ::arrow::util::SafeCopy<uint32_t>(v);
- return PutVlqInt((u_v << 1) ^ (u_v >> 31));
+ uint32_t u_v = ::arrow::util::SafeCopy<uint32_t>(v);
+ v = (u_v << 1) ^ (v >> 31);
+ u_v = ::arrow::util::SafeCopy<uint32_t>(v);
Review comment:
Using safe-copy instead could also work. SafeCopy (and other methods in
ubsan.h) are mostly to avoid undefined behavior. The most common case of this
is when trying to read possibly unaligned values.
SafeCopy is equivelant to the new
[std::bit_cast](https://en.cppreference.com/w/cpp/numeric/bit_cast)
--
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]