diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-02-09 10:49:15 -0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-16 12:55:36 +0000 |
commit | e136b7b33c6b304d59199452c85acbe049dc4ccd (patch) | |
tree | e74642751de662c02b86195e48e70aaf49064e4c /src | |
parent | c4160b6e020fabe89d065813e6e179abedba2fcc (diff) | |
download | qtbase-e136b7b33c6b304d59199452c85acbe049dc4ccd.tar.gz |
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;
| ^~~~~~
Change-Id: I74249c52dc02478ba93cfffd16d232b275d5d216
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit dcdb8884e732802c92ae96b6d5b21331ddaef55b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qfreelist_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index efd78c0c4d..262661122c 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -161,7 +161,7 @@ class QFreeList return i; x -= size; } - Q_ASSERT(false); + Q_UNREACHABLE(); return -1; } |