Use placement operator new to value-initialize malloc'ed data
Fixes a GCC12 warning about use of uninitialized data in Base.
In member function ‘QSpecialIntegerAccessor<S, pos, width, T>& QSpecialIntegerAccessor<S, pos, width, T>::operator=(Type) [with S = QLittleEndianStorageType<unsigned int>; int pos = 0; int width = 1; T = unsigned int]’,
inlined from ‘void QSpecialIntegerBitfieldUnion<S, Accessors>::set(typename A::Type) [with A = QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 1, unsigned int>; S = QLittleEndianStorageType<unsigned int>; Accessors = {QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 1, unsigned int>, QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 1, 31, unsigned int>}]’ at qendian_p.h:219:21,
inlined from ‘void QBinaryJsonPrivate::Base::setIsObject()’ at qbinaryjson_p.h:329:65,
inlined from ‘void QBinaryJsonPrivate::MutableData::compact()’ at qbinaryjson.cpp:266:23:
qendian_p.h:184:40: error: ‘((Storage*)h)[3].QSpecialIntegerStorage<QLittleEndianStorageType<unsigned int> >::val’ may be used uninitialized [-Werror=maybe-uninitialized]
184 | UnsignedType i = S::fromSpecial(storage->val);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In member function ‘QSpecialIntegerAccessor<S, pos, width, T>& QSpecialIntegerAccessor<S, pos, width, T>::operator=(Type) [with S = QLittleEndianStorageType<unsigned int>; int pos = 0; int width = 1; T = unsigned int]’,
inlined from ‘void QSpecialIntegerBitfieldUnion<S, Accessors>::set(typename A::Type) [with A = QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 1, unsigned int>; S = QLittleEndianStorageType<unsigned int>; Accessors = {QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 1, unsigned int>, QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 1, 31, unsigned int>}]’ at qendian_p.h:219:21,
inlined from ‘void QBinaryJsonPrivate::Base::setIsArray()’ at qbinaryjson_p.h:332:64,
inlined from ‘void QBinaryJsonPrivate::MutableData::compact()’ at qbinaryjson.cpp:268:22:
qendian_p.h:184:40: error: ‘((Storage*)h)[3].QSpecialIntegerStorage<QLittleEndianStorageType<unsigned int> >::val’ may be used uninitialized [-Werror=maybe-uninitialized]
184 | UnsignedType i = S::fromSpecial(storage->val);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
Pick-to: 6.3 6.2
Fixes: QTBUG-103927
Change-Id: Iba16e8ea451b444ab213fffd16f48fa54035bbf6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>