QOperatingSystemVersion: fix UB (invalid static_cast)

When the QOSVBase we're constructing from isn't an actual
QOSVUnexported, the cast from QOSVBase to QOSVUnexported is
invalid. Instead of casting, add an QOSVUnexported(QOSVBase) ctor and
just call that.

Amends 215677818470e48e9090d7ae4411e1fea62207b8.

Change-Id: I7352a044b62086585f1b036433f9b8779c77ac9d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit e3c831dc558de7e83c81fe09644db18013d5dd65)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 175f2c4f3312215050ae1bf982b33fb668a8c6b6)
This commit is contained in:
Marc Mutz 2024-02-21 15:24:58 +01:00 committed by Qt Cherry-pick Bot
parent 419ee4b34c
commit 3b9683bf47

View File

@ -111,6 +111,8 @@ class QOperatingSystemVersionUnexported : public QOperatingSystemVersionBase
{
public:
using QOperatingSystemVersionBase::QOperatingSystemVersionBase;
constexpr QOperatingSystemVersionUnexported(QOperatingSystemVersionBase other) noexcept
: QOperatingSystemVersionBase(other) {}
#else
class QOperatingSystemVersion : public QOperatingSystemVersionBase
{
@ -224,7 +226,7 @@ public:
static constexpr QOperatingSystemVersionBase MacOSVentura { QOperatingSystemVersionBase::MacOS, 13, 0 };
constexpr QOperatingSystemVersion(const QOperatingSystemVersionBase &osversion)
: QOperatingSystemVersionUnexported(static_cast<const QOperatingSystemVersionUnexported &>(osversion)) {}
: QOperatingSystemVersionUnexported(osversion) {}
constexpr QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1)
: QOperatingSystemVersionUnexported(QOperatingSystemVersionBase::OSType(osType), vmajor, vminor,