QtQml: Avoid maybe-uninitialized warnings in QJSPrimitiveValue
The compiler can't see that we only access m_string if it has previously been initialized. However, we can just zero the storage on construction. Pick-to: 6.9 6.8 6.5 Fixes: QTBUG-135367 Change-Id: I1b04d81e18063650501bdc24474c9672e999189d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
53bd0bb6b0
commit
b417a509f5
|
@ -932,10 +932,14 @@ private:
|
|||
}
|
||||
|
||||
union {
|
||||
bool m_bool = false;
|
||||
bool m_bool;
|
||||
int m_int;
|
||||
double m_double;
|
||||
QString m_string;
|
||||
|
||||
// Dummy value to trigger initialization of the whole storage.
|
||||
// We don't want to see maybe-uninitialized warnings every time we access m_string.
|
||||
std::byte m_zeroInitialize[sizeof(QString)] = {};
|
||||
};
|
||||
|
||||
Type m_type = Undefined;
|
||||
|
|
Loading…
Reference in New Issue