summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2024-05-22 13:14:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-05-22 23:37:05 +0000
commitb4df307723c74346186fd70beddbd134408e2ee8 (patch)
tree7f35d558111d27cf437f3ea4bf9e67b80001d791
parentCMake: Fix DEBUG_POSTFIX to apply to macOS multi-config builds (diff)
downloadqtbase-b4df307723c74346186fd70beddbd134408e2ee8.tar.xz
qtbase-b4df307723c74346186fd70beddbd134408e2ee8.zip
tst_QByteArrayView: expose constExpr() test to non-ubsan GCC builds
Because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962, and because marking constExpr() as __attribute__((no_sanitize_undefined)) doesn't fix a thing, we opted to disable the triggering parts of constExpr() from all GCC builds. This is, of course, unfortunate, since it meaningfully reduces compile-time coverage in the general case for a rather obscure build type most won't ever use. While GCC doesn't give us a predefined macro to check for in the .cpp file, the cmake build system knows whether we use ubsan, so just define a macro of our own. As a drive-by, simplify GCC detection by using Q_CC_GCC_ONLY. Amends de6a004bc5a5b9cd3ecfbb14818bb42fb1ecfd68. Pick-to: 6.5 6.2 Task-number: QTBUG-101307 Change-Id: I4be5bd103b9d2386b2ac9fd22e0c34f9c63fee04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 564be117fece258f661a20e5c81166fa658f5e84) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/corelib/text/qbytearrayview/CMakeLists.txt7
-rw-r--r--tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp3
2 files changed, 8 insertions, 2 deletions
diff --git a/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt b/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt
index c78a81c7bd..8922ae2267 100644
--- a/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt
+++ b/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt
@@ -15,3 +15,10 @@ qt_internal_add_test(tst_qbytearrayview
SOURCES
tst_qbytearrayview.cpp
)
+
+if(QT_FEATURE_sanitize_undefined)
+ qt_internal_extend_target(tst_qbytearrayview
+ DEFINES
+ QT_SANITIZE_UNDEFINED # GCC (in)famously doesn't provide a predefined macro for this
+ )
+endif()
diff --git a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
index 00bde2a546..5cfce32586 100644
--- a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
+++ b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
@@ -262,10 +262,9 @@ void tst_QByteArrayView::constExpr() const
static_assert(!bv2.empty());
static_assert(bv2.size() == 5);
}
-#if !defined(Q_CC_GNU) || defined(Q_CC_CLANG)
+#if !defined(Q_CC_GNU_ONLY) || !defined(QT_SANITIZE_UNDEFINED)
// Below checks are disabled because of a compilation issue with GCC and
// -fsanitize=undefined. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962.
- // Note: Q_CC_GNU is also defined for Clang, so we need to check that too.
{
static constexpr char hello[] = "Hello";
constexpr QByteArrayView bv(hello);