Skip to content

Commit

Permalink
Silence GCC 8 warning on memcpy of movable types
Browse files Browse the repository at this point in the history
This is similar to commit 342bb5b.

From GCC 8:

qarraydataops.h:84:17: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class QStringRef’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
[etc.]

Change-Id: I41d006aac5bc48529845fffd150e817e64973bec
Reviewed-by: Ville Voutilainen <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
thiagomacieira committed Feb 4, 2018
1 parent 1514b4e commit c26c5b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/corelib/tools/qarraydataops.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ struct QPodArrayOps
Q_ASSERT(b < e);
Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size));

::memcpy(this->end(), b, (e - b) * sizeof(T));
::memcpy(static_cast<void *>(this->end()), static_cast<const void *>(b),
(e - b) * sizeof(T));
this->size += e - b;
}

Expand Down
4 changes: 2 additions & 2 deletions src/corelib/tools/qvarlengtharray.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::append(const T *abuf, in
while (s < asize)
new (ptr+(s++)) T(*abuf++);
} else {
memcpy(&ptr[s], abuf, increment * sizeof(T));
memcpy(static_cast<void *>(&ptr[s]), static_cast<const void *>(abuf), increment * sizeof(T));
s = asize;
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
QT_RETHROW;
}
} else {
memcpy(ptr, oldPtr, copySize * sizeof(T));
memcpy(static_cast<void *>(ptr), static_cast<const void *>(oldPtr), copySize * sizeof(T));
}
}
s = copySize;
Expand Down

0 comments on commit c26c5b7

Please sign in to comment.