diff --git a/src/corelib/kernel/qapplicationstatic.h b/src/corelib/kernel/qapplicationstatic.h index f311da5d77e..2f2cab9174e 100644 --- a/src/corelib/kernel/qapplicationstatic.h +++ b/src/corelib/kernel/qapplicationstatic.h @@ -9,6 +9,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE namespace QtGlobalStatic { @@ -36,7 +38,7 @@ template struct ApplicationHolder static PlainType *realPointer() { - return reinterpret_cast(&storage); + return std::launder(reinterpret_cast(&storage)); } // called from QGlobalStatic::instance() @@ -46,7 +48,7 @@ template struct ApplicationHolder return realPointer(); QMutexLocker locker(&mutex); if (guard.loadRelaxed() == QtGlobalStatic::Uninitialized) { - QAS::innerFunction(realPointer()); + QAS::innerFunction(&storage); QObject::connect(QCoreApplication::instance(), &QObject::destroyed, reset); guard.storeRelaxed(QtGlobalStatic::Initialized); }