path: root/src
diff options
authorThiago Macieira <>2018-01-29 21:46:40 -0800
committerThiago Macieira <>2018-02-04 08:33:56 +0000
commit1514b4e85336245ef130deca5839267dba7b2e32 (patch)
tree99f64f93edf982611edc178be2c664cc15176724 /src
parentb7e436738756b1d5d7a45201b7a7204d7fe128a1 (diff)
Silence GCC 8 warning on memcpy of class Value to to class offset
From GCC 8: error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of type ‘QJsonPrivate::offset’ {aka ‘class QSpecialInteger<QLittleEndianStorageType<unsigned int> >’} with ‘private’ member ‘QSpecialInteger<QLittleEndianStorageType<unsigned int> >::val’ from an array of ‘const value_type’ {aka ‘const class QJsonPrivate::Value’}; use assignment or copy-initialization instead [-Werror=class-memaccess] Both types are standard layout and have the same initial sequence (one uint member), so this is a valid copy. The only difference between the two is that QSpecialInteger has a private member, whereas in the bitfield it's public. Change-Id: I41d006aac5bc48529845fffd150e80585fd24db7 Reviewed-by: Ville Voutilainen <> Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src')
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index d4cc4b81df..255dc2ee4e 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -297,7 +297,8 @@ QJsonArray QJsonArray::fromVariantList(const QVariantList &list)
array.a->tableOffset = currentOffset;
if (!array.detach2(sizeof(QJsonPrivate::offset)*values.size()))
return QJsonArray();
- memcpy(array.a->table(), values.constData(), values.size()*sizeof(uint));
+ memcpy(static_cast<void *>(array.a->table()),
+ static_cast<const void *>(values.constData()), values.size()*sizeof(uint));
array.a->length = values.size();
array.a->size = currentOffset + sizeof(QJsonPrivate::offset)*values.size();