QFreeList: replace a Q_ASSERT(false) with Q_UNREACHABLE()
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<void>]’, inlined from ‘_Tp* std::atomic<_Tp*>::load(std::memory_order) const [with _Tp = QFreeListElement<void>]’ at atomic:579:25, inlined from ‘static T QAtomicOps<X>::loadAcquire(const std::atomic<T>&) [with T = QFreeListElement<void>*; X = QFreeListElement<void>*]’ at thread/qatomic_cxx11.h:249:29, inlined from ‘X* QBasicAtomicPointer<X>::loadAcquire() const [with X = QFreeListElement<void>]’ at thread/qbasicatomic.h:233:64, inlined from ‘int QFreeList<T, ConstantsType>::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 <marc.mutz@qt.io>
This commit is contained in:
parent
cb9ef46c77
commit
dcdb8884e7
@ -160,7 +160,7 @@ class QFreeList
|
||||
return i;
|
||||
x -= size;
|
||||
}
|
||||
Q_ASSERT(false);
|
||||
Q_UNREACHABLE();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user