qt5base-lts/tests/auto
Giuseppe D'Angelo e8f5f20319 QMetaType: fix value-initialization in a corner case
If a type is trivially default constructible, QMetaType (and QVariant)
think that it can be built and value-initialized by zero-filling a
region of storage and then "blessing" that storage as an actual instance
of the type to build. This is done as an optimization.

This doesn't work for all trivially constructible types. For instance,
on the Itanium C++ ABI, pointers to data members are actually
value-initialized (= zero-initialized, = initialized to null) with the
value -1:

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers

This means that a type like

  struct A { int A::*ptr; };

is trivially constructible, but its value initialization is not
equivalent to zero-filling its storage.

Since C++ does not offer a type trait we can use for the detection that
we want to do here, and since we have also decided that Q_PRIMITIVE_TYPE
isn't that trait (it just means trivially copyable / destructible), I'm
rolling out a custom type trait for the purpose.

This type trait is private for the moment being (there's no
Q_DECLARE_TYPEINFO for it), and limited to the subset of scalar types
that we know can be value-initialized by memset(0) into their storage
(basically, all of them, except for pointers to data members).

The fix tries to keep the pre-existing semantics of
`QMetaType::NeedsConstruction`. Before, the flag was set for types which
were not trivially default constructible. That included types that
aren't default constructible, or types that cannot do so trivially.
I've left that meaning unchanged, and simply amended the "trivial" part
with the custom trait. A fix there (to clarify the semantics) can be
done as a separate change.

Change-Id: Id8da6acb913df83fc87e5d37e2349a4628e72e91
Pick-to: 6.5
Fixes: QTBUG-109594
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-30 01:51:08 +01:00
..
bic/data Revert "Add binary compatibility file generated against 6.4.0" 2022-11-17 13:52:02 +00:00
cmake Bump version to 6.6.0 2022-12-14 20:19:01 +02:00
concurrent Skip tst_qconcurrentrun completely if running under an emulator 2022-12-19 15:31:10 +00:00
corelib QMetaType: fix value-initialization in a corner case 2022-12-30 01:51:08 +01:00
dbus Adapt to QTimeZone replacing Qt::TimeSpec usage 2022-12-10 06:39:44 +01:00
gui QTextImageHandler: Resolve Nx images correctly for file or qrc URLs 2022-12-22 19:19:33 +01:00
guiapplauncher Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00
network Adapt to QTimeZone replacing Qt::TimeSpec usage 2022-12-10 06:39:44 +01:00
opengl Remove the qmake project files 2021-01-07 15:32:28 +01:00
other Remove blacklisting for OpenSUSE LEAP in gestures 2022-12-14 15:47:25 +00:00
printsupport Port from qAsConst() to std::as_const() 2022-10-11 23:17:18 +02:00
shared Don't hide object replacement char except in rich text 2022-12-14 19:19:01 +01:00
sql SQL: remove unneeded test functions 2022-12-22 19:26:51 +01:00
testlib Adapt to QTimeZone replacing Qt::TimeSpec usage 2022-12-10 06:39:44 +01:00
tools dbus: Fix path to moc file in generated qdbusxml2cpp 2022-12-16 17:21:57 +00:00
wasm Fix typo in QWasmWindowStack's name 2022-10-20 16:36:23 +02:00
widgets Use minimum size for in tst_QDockWidget::createTestWidgets 2022-12-29 13:53:40 +00:00
xml QDomDocument: ensure a defined order of attributes when saving 2022-12-09 16:29:11 +01:00
CMakeLists.txt Add forwarding of CMake variables to ABI-specific external projects 2022-12-08 23:24:22 +01:00
network-settings.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00