diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-06-27 14:57:58 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 21:31:40 +0200 |
commit | 563fbe79e52cfbf904d2e26d775a2160980fa41a (patch) | |
tree | 901ee0a25e007a94c8101573c444290cde7b463d /src | |
parent | 9117e3850b9d395a9741fa4b63c5b59ea7767390 (diff) |
Try to workaround bogus compiler warning in gcc 9 for ARMv7
../../src/corelib/io/qurlidna.cpp: In function ‘QString qt_ACE_do(QStringView, AceOperation, AceLeadingDot)’:
../../src/corelib/io/qurlidna.cpp:2543:23: error: ‘int __builtin_memcmp_eq(const void*, const void*, unsigned int)’
reading 8 bytes from a region of size 2 [-Werror=stringop-overflow=]
if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0)
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
In function ‘bool operator==(const QByteArray&, const QByteArray&)’,
inlined from ‘virtual void (* QLinuxFbIntegration::platformFunction(const QByteArray&) const)()’
at ../../src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp:185:18:
include/QtCore/../../../../src/corelib/text/qbytearray.h:571:45: error:
‘int __builtin_memcmp_eq(const void*, const void*, unsigned int)’ reading 17 bytes from
a region of size 1 [-Werror=stringop-overflow=]
The warnings/errors are bogus. Fix them by using QStringView::sliced() and de-inlining the
comparison operator for QByteArray.
Change-Id: I24956fe74a7989e75cd03d717570b8fca493ab23
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qurlidna.cpp | 3 | ||||
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 4 | ||||
-rw-r--r-- | src/corelib/text/qbytearray.h | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index f034509bcc..9542122a82 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2548,8 +2548,7 @@ QString qt_ACE_do(QStringView domain, AceOperation op, AceLeadingDot dot) // ACE form domains contain only ASCII characters, but we can't consider them simple // is this an ACE form? // the shortest valid ACE domain is 6 characters long (U+0080 would be 1, but it's not allowed) - static const ushort acePrefixUtf16[] = { 'x', 'n', '-', '-' }; - if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0) + if (QStringView{result}.sliced(prevLen).startsWith(u"xn--")) simple = false; } diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 299c723a55..ee559c6d75 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -3104,6 +3104,10 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) \sa QByteArray::compare() */ +bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept +{ + return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); +} /*! \fn bool operator==(const QByteArray &a1, const char *a2) \relates QByteArray diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 045a05c54a..1e0a671981 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -567,8 +567,7 @@ inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) cons return cs == Qt::CaseSensitive ? qstrcmp(*this, a) : qstrnicmp(data(), size(), a.data(), a.size()); } -inline bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept -{ return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); } +Q_CORE_EXPORT bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept; inline bool operator==(const QByteArray &a1, const char *a2) noexcept { return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); } inline bool operator==(const char *a1, const QByteArray &a2) noexcept |