Skip to content

Commit

Permalink
Silence GCC 8 warnings in QString
Browse files Browse the repository at this point in the history
qtbase/src/corelib/tools/qstring.cpp:3539:67: error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class QChar’ from an array of ‘short unsigned int’ [-Werror=class-memaccess]
             memcpy(uc, d->data() + copystart, size * sizeof(QChar));

Change-Id: Ic601bed1a1f9e1b6f0ac1f9e58f1dcadb50ad724
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
  • Loading branch information
villevoutilainen committed Feb 14, 2018
1 parent b349427 commit 77582f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/corelib/tools/qstring.cpp
Expand Up @@ -3536,14 +3536,14 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
while (i < pos) {
int copyend = replacements[i].pos;
int size = copyend - copystart;
memcpy(uc, d->data() + copystart, size * sizeof(QChar));
memcpy(static_cast<void*>(uc), static_cast<const void *>(d->data() + copystart), size * sizeof(QChar));
uc += size;
memcpy(uc, after.d->data(), al * sizeof(QChar));
memcpy(static_cast<void *>(uc), static_cast<const void *>(after.d->data()), al * sizeof(QChar));
uc += al;
copystart = copyend + replacements[i].length;
i++;
}
memcpy(uc, d->data() + copystart, (d->size - copystart) * sizeof(QChar));
memcpy(static_cast<void *>(uc), static_cast<const void *>(d->data() + copystart), (d->size - copystart) * sizeof(QChar));
newstring.resize(newlen);
*this = newstring;
caretMode = QRegExp::CaretWontMatch;
Expand Down Expand Up @@ -5766,7 +5766,7 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const
while (padlen--)
* uc++ = fill;
if (len)
memcpy(uc, d->data(), sizeof(QChar)*len);
memcpy(static_cast<void *>(uc), static_cast<const void *>(d->data()), sizeof(QChar)*len);
} else {
if (truncate)
result = left(width);
Expand Down

0 comments on commit 77582f1

Please sign in to comment.