Silence GCC 8 warning on memcpy of movable types

This is similar to commit 342bb5b03a.

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 <ville.voutilainen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira 2018-01-29 21:46:40 -08:00
parent 1514b4e853
commit c26c5b7d0d
2 changed files with 4 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
}
}
@ -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;