tst_QByteArrayView:: disable failing constexpr checks for GCC

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 <edward.welbourne@qt.io>
This commit is contained in:
Sona Kurazyan 2022-03-30 14:48:50 +02:00
parent 2bf20e38b0
commit de6a004bc5

View File

@ -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);