From 1b076b3027e0e059ba37fc9332c65e6354516a95 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 May 2024 13:43:44 +0200 Subject: [PATCH] tst_QByteArrayView: (re)fix GCC ubsan build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the constexpr fromArray() check from fromArray() to constExpr() where there is already the protection necessary to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962. Amends bbe7570ddcc6fcce707a355b76d2d0024c44ea38(!). (iow: 6.0, and no, I don't know why it became a problem only now) Pick-to: 6.5 6.2 Change-Id: Id9d2a08175709f8bf85b3b192e7aa49783b9e714 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira (cherry picked from commit 6d28744e43c113b0f94b2132d5904d85a18d81a3) Reviewed-by: Qt Cherry-pick Bot --- .../auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp index 5cfce32586e..001668691d2 100644 --- a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp +++ b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp @@ -306,6 +306,9 @@ void tst_QByteArrayView::constExpr() const static_assert(bv.back() == 'o'); static_assert(bv.last() == 'o'); + constexpr auto bv2 = QByteArrayView::fromArray(hello); + QCOMPARE_EQ(bv, bv2); + constexpr std::string_view sv = bv; static_assert(bv.size() == sv.size()); #ifdef AMBIGUOUS_CALL // QTBUG-108805 @@ -383,7 +386,7 @@ void tst_QByteArrayView::fromArray() const { static constexpr char hello[] = "Hello\0abc\0\0."; - constexpr QByteArrayView bv = QByteArrayView::fromArray(hello); + const QByteArrayView bv = QByteArrayView::fromArray(hello); QCOMPARE(bv.size(), 13); QVERIFY(!bv.empty()); QVERIFY(!bv.isEmpty());