From de6a004bc5a5b9cd3ecfbb14818bb42fb1ecfd68 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 30 Mar 2022 14:48:50 +0200 Subject: [PATCH] tst_QByteArrayView:: disable failing constexpr checks for GCC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When comiling with ubsan, GCC is being too restrictive and ignores that 'static constexpr char []' can never be nullptr. It tries to evaluate the comparison with nullptr, and fails with: error: ‘(((const char*)(& hello)) == 0)’ is not a constant Disable the checks when compiling with GCC. Fixes: QTBUG-101307 Pick-to: 6.3 6.2 Change-Id: I8322bb7cb326e06cd03b8b107c46a494c825087b Reviewed-by: Edward Welbourne --- .../auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp index 8e234d5863..840ca2719a 100644 --- a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp +++ b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp @@ -270,6 +270,10 @@ void tst_QByteArrayView::constExpr() const static_assert(!bv2.empty()); static_assert(bv2.size() == 5); } +#if !defined(Q_CC_GNU) || defined(Q_CC_CLANG) || defined(Q_CC_INTEL) + // 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 and ICC, so we need to check those too. { static constexpr char hello[] = "Hello"; constexpr QByteArrayView bv(hello); @@ -304,6 +308,7 @@ void tst_QByteArrayView::constExpr() const static_assert(bv.back() == 'o'); static_assert(bv.last() == 'o'); } +#endif { constexpr char *null = nullptr; constexpr QByteArrayView bv(null);