summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobalstatic.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-31 17:19:06 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-26 17:15:02 +0100
commit80b6bcc385863a38d499685af9b8e857e46cbdba (patch)
tree252b745a2b8dd617224f49cf89139cd5baef317c /src/corelib/global/qglobalstatic.h
parentedb64351cd0896d27af15d54d5fa868c7567eced (diff)
Short live Q_CONSTINIT!
It expands to the first available of - constinit (C++20) - [[clang::require_constant_initialization]] (Clang) - __constinit (GCC >= 10) Use it around the code (on and near static QBasicAtomic; this patch makes no attempt to find all statics in qtbase). [ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT. Fixes: QTBUG-100484 Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/global/qglobalstatic.h')
-rw-r--r--src/corelib/global/qglobalstatic.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h
index aaa01262a7..beecc1f000 100644
--- a/src/corelib/global/qglobalstatic.h
+++ b/src/corelib/global/qglobalstatic.h
@@ -63,7 +63,7 @@ template <typename QGS> union Holder
using PlainType = std::remove_cv_t<Type>;
static constexpr bool ConstructionIsNoexcept = noexcept(QGS::innerFunction(nullptr));
- static inline QBasicAtomicInteger<qint8> guard = { QtGlobalStatic::Uninitialized };
+ Q_CONSTINIT static inline QBasicAtomicInteger<qint8> guard = { QtGlobalStatic::Uninitialized };
// union's sole member
PlainType storage;
@@ -144,7 +144,7 @@ protected:
new (pointer) QGS_Type ARGS; \
} \
}; } \
- static QGlobalStatic<QtGlobalStatic::Holder<Q_QGS_ ## NAME>> NAME; \
+ Q_CONSTINIT static QGlobalStatic<QtGlobalStatic::Holder<Q_QGS_ ## NAME>> NAME; \
QT_WARNING_POP
/**/