QLogging: fix potential UB in QBasicAtomic initialization
Until C++17 (inclusive), a default-constructed std::atomic object can, officially, only be initialized with a call to std::atomic_init, for which QBasicAtomic doesn't have API. It is even unclear whether zero-initialization of static and thread-local objects will cause the object to be initialized. But initialization with = {} is definitely fishy, because that, by definition, invokes the problematic default constructor. So make the initialization explict with Q_BASIC_ATOMIC_INITIALIZER(0) instead. Amends 4a154170773199f5b3376496c7b1a1c4530744e9. Task-number: QTBUG-137465 Pick-to: 6.10 Change-Id: I177e05c09e20e0830af7bf1ccb650afc860ab9d5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
0ba05ca500
commit
231069963d
@ -181,8 +181,8 @@ static bool isFatalCountDown(const char *varname, QBasicAtomicInt &n)
|
||||
return v == ImmediatelyFatal;
|
||||
}
|
||||
|
||||
Q_CONSTINIT static QBasicAtomicInt fatalCriticalsCount = {};
|
||||
Q_CONSTINIT static QBasicAtomicInt fatalWarningsCount = {};
|
||||
Q_CONSTINIT static QBasicAtomicInt fatalCriticalsCount = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt fatalWarningsCount = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
static bool isFatal(QtMsgType msgType)
|
||||
{
|
||||
switch (msgType){
|
||||
|
Loading…
x
Reference in New Issue
Block a user