From dcdb8884e732802c92ae96b6d5b21331ddaef55b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 9 Feb 2022 10:49:15 -0800 Subject: [PATCH] QFreeList: replace a Q_ASSERT(false) with Q_UNREACHABLE() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Q_ASSERT goes away in release builds, Q_UNREACHABLE() does not. This also solves the GCC 12 warning about out-of-bounds access in QAbstractEventDispatcherPrivate::allocateTimerId(): In member function ‘_PTp* std::__atomic_base<_PTp*>::load(std::memory_order) const [with _PTp = QFreeListElement]’, inlined from ‘_Tp* std::atomic<_Tp*>::load(std::memory_order) const [with _Tp = QFreeListElement]’ at atomic:579:25, inlined from ‘static T QAtomicOps::loadAcquire(const std::atomic&) [with T = QFreeListElement*; X = QFreeListElement*]’ at thread/qatomic_cxx11.h:249:29, inlined from ‘X* QBasicAtomicPointer::loadAcquire() const [with X = QFreeListElement]’ at thread/qbasicatomic.h:233:64, inlined from ‘int QFreeList::next() [with T = void; ConstantsType = QtTimerIdFreeListConstants]’ at qfreelist_p.h:245:34, inlined from ‘static int QAbstractEventDispatcherPrivate::allocateTimerId()’ at kernel/qabstracteventdispatcher.cpp:99:24: bits/atomic_base.h:820:31: warning: ‘long unsigned int __atomic_load_8(const volatile void*, int)’ writing 8 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] 820 | return __atomic_load_n(&_M_p, int(__m)); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ In file included from qglobalstatic.h:1, from qglobal.h:1395: qglobalstatic.h: In static member function ‘static int QAbstractEventDispatcherPrivate::allocateTimerId()’: qglobalstatic.h:127:23: note: at offset -8 into destination object ‘holder’ of size 56 127 | static Holder holder; | ^~~~~~ Pick-to: 5.15 6.2 6.3 Change-Id: I74249c52dc02478ba93cfffd16d232b275d5d216 Reviewed-by: Marc Mutz --- src/corelib/tools/qfreelist_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index f54e5aad65a..3550dd511ac 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -160,7 +160,7 @@ class QFreeList return i; x -= size; } - Q_ASSERT(false); + Q_UNREACHABLE(); return -1; }