martin-g commented on code in PR #3740:
URL: https://github.com/apache/avro/pull/3740#discussion_r3128626914


##########
lang/c++/include/avro/buffer/detail/BufferDetail.hh:
##########
@@ -320,7 +320,7 @@ public:
         if (freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
             // fast path, there's enough room in the writeable chunk to just
             // straight out copy it
-            *(reinterpret_cast<T *>(writeChunks_.front().tellWritePos())) = 
val;
+            memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));
             postWrite(sizeof(T));
         } else {
             // need to fixup chunks first, so use the regular memcpy

Review Comment:
   In the `else` clause the comment mentions `memcpy` but still uses 
`reinterpret_cast`.
   
   I am not C++ dev, so I don't know whether this needs fixing or not.



##########
lang/c++/include/avro/buffer/detail/BufferDetail.hh:
##########
@@ -320,7 +320,7 @@ public:
         if (freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
             // fast path, there's enough room in the writeable chunk to just
             // straight out copy it
-            *(reinterpret_cast<T *>(writeChunks_.front().tellWritePos())) = 
val;
+            memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));

Review Comment:
   Does the file need `#include <cstring>` ?
   
   Also, at some places I have seen `std::xyz()` and others skip `std::`. 



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