QStringBuilder: fix warning about memcpying onto QChar

Which is not a trivial class.

qstringbuilder.h: In instantiation of 'static void QConcatenable<const char16_t [N]>::appendTo(const char16_t*, QChar*&) [with long long int N = 6]':
qstringbuilder.h:402:35:   required from 'static void QConcatenable<QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> > >::appendTo(const type&, T*&) [with T = QChar; A = char16_t [6]; B = QString; QConcatenable<QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> > >::type = QStringBuilder<char16_t [6], QString>]'
qstringbuilder.h:460:52:   required from 'QString& operator+=(QString&, const QStringBuilder<A, B>&) [with A = char16_t [6]; B = QString]'
/home/tjmaciei/src/qt/qt6-release/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp:1762:75:   required from here
qstringbuilder.h:338:15: error: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'class QChar' from an array of 'const char16_t' [-Werror=class-memaccess]

Change-Id: Iddb933f281024939b6acfffd1689cf320c84873c
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Thiago Macieira 2021-06-18 15:55:54 -07:00
parent 100fb6c3a0
commit a20a424066

View File

@ -335,7 +335,7 @@ template <qsizetype N> struct QConcatenable<const char16_t[N]> : private QAbstra
static qsizetype size(const char16_t[N]) { return N - 1; }
static void appendTo(const char16_t a[N], QChar *&out)
{
memcpy(out, a, (N - 1) * sizeof(char16_t));
memcpy(static_cast<void *>(out), a, (N - 1) * sizeof(char16_t));
out += N - 1;
}
};