From a20a4240668faa0e6c961b90266918628f9f5484 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Jun 2021 15:55:54 -0700 Subject: [PATCH] QStringBuilder: fix warning about memcpying onto QChar Which is not a trivial class. qstringbuilder.h: In instantiation of 'static void QConcatenable::appendTo(const char16_t*, QChar*&) [with long long int N = 6]': qstringbuilder.h:402:35: required from 'static void QConcatenable, > >::appendTo(const type&, T*&) [with T = QChar; A = char16_t [6]; B = QString; QConcatenable, > >::type = QStringBuilder]' qstringbuilder.h:460:52: required from 'QString& operator+=(QString&, const QStringBuilder&) [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 --- src/corelib/text/qstringbuilder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qstringbuilder.h b/src/corelib/text/qstringbuilder.h index ec5ef6eb7c..5a6a531e74 100644 --- a/src/corelib/text/qstringbuilder.h +++ b/src/corelib/text/qstringbuilder.h @@ -335,7 +335,7 @@ template struct QConcatenable : 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(out), a, (N - 1) * sizeof(char16_t)); out += N - 1; } };