From 80256b3683ca95907e71a7c127c74b865b1f0fe7 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Tue, 7 Sep 2021 15:18:06 +0200 Subject: [PATCH] Revert "QUrl: Remove explicit casts to {const,} void*" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 63c1e7c4a105df0b61f0cd1f8193820cdf026ae3. It caused the following compilation error with g++-11. error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class QChar’ from an array of ‘const char16_t’ Fixes: QTBUG-96268 Change-Id: I2680b15aba8d0d867092391fcee3815e7fa4c0bc Reviewed-by: Ievgenii Meshcheriakov Reviewed-by: Edward Welbourne Reviewed-by: Shawn Rutledge Reviewed-by: Thiago Macieira --- src/corelib/io/qurlrecode.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index 985e4b5c28..fd5accb108 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -591,7 +591,7 @@ static qsizetype decode(QString &appendTo, QStringView in) const int origSize = appendTo.size(); appendTo.resize(origSize + (end - begin)); QChar *output = appendTo.data() + origSize; - memcpy(output, begin, (input - begin) * sizeof(QChar)); + memcpy(static_cast(output), static_cast(begin), (input - begin) * sizeof(QChar)); output += input - begin; while (input != end) { @@ -601,7 +601,8 @@ static qsizetype decode(QString &appendTo, QStringView in) if (Q_UNLIKELY(end - input < 3 || !isHex(input[1]) || !isHex(input[2]))) { // badly-encoded data appendTo.resize(origSize + (end - begin)); - memcpy(appendTo.begin() + origSize, begin, (end - begin) * sizeof(*end)); + memcpy(static_cast(appendTo.begin() + origSize), + static_cast(begin), (end - begin) * sizeof(*end)); return end - begin; }