[PATCH] D50296: Fix few g++ 8 warning with non obvious copy object operations

David CARLIER via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 4 04:55:10 PDT 2018


devnexen created this revision.
devnexen added reviewers: dblaikie, dexonsmith.
devnexen created this object with visibility "All Users".
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50296

Files:
  include/llvm/ADT/DenseMap.h
  include/llvm/ADT/SmallVector.h


Index: include/llvm/ADT/SmallVector.h
===================================================================
--- include/llvm/ADT/SmallVector.h
+++ include/llvm/ADT/SmallVector.h
@@ -299,7 +299,7 @@
     // use memcpy here. Note that I and E are iterators and thus might be
     // invalid for memcpy if they are equal.
     if (I != E)
-      memcpy(Dest, I, (E - I) * sizeof(T));
+      memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
   }
 
   /// Double the size of the allocated memory, guaranteeing space for at
@@ -310,7 +310,7 @@
   void push_back(const T &Elt) {
     if (LLVM_UNLIKELY(this->size() >= this->capacity()))
       this->grow();
-    memcpy(this->end(), &Elt, sizeof(T));
+    memcpy(reinterpret_cast<void *>(this->end()), &Elt, sizeof(T));
     this->set_size(this->size() + 1);
   }
 
Index: include/llvm/ADT/DenseMap.h
===================================================================
--- include/llvm/ADT/DenseMap.h
+++ include/llvm/ADT/DenseMap.h
@@ -393,7 +393,7 @@
     setNumTombstones(other.getNumTombstones());
 
     if (isPodLike<KeyT>::value && isPodLike<ValueT>::value)
-      memcpy(getBuckets(), other.getBuckets(),
+      memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
              getNumBuckets() * sizeof(BucketT));
     else
       for (size_t i = 0; i < getNumBuckets(); ++i) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50296.159180.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180804/6d8f4004/attachment.bin>


More information about the llvm-commits mailing list