summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject_p.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-04-04 08:40:43 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-04-13 20:17:23 -0700
commitbc6087fce259fe600c5d12785fa5f293f129965b (patch)
treeb387bcd1173e5656463fe6cd3324f5ed36a52504 /src/corelib/kernel/qobject_p.h
parent974a7bd6e0ece921e699df6c2b346f944f723b83 (diff)
QObjectPrivate: use ConnectionList's constructor instead of copy-assignment
For all new elements, this is the correct thing to do. This seems to work around an MSVC compiler bug on ARM64. It also seems to generate better code for x86-64 too, as a nice bonus. See: https://developercommunity.visualstudio.com/t/codegen-elides-initializers-when-copying/10004323 Before: https://msvc.godbolt.org/z/Wcd4haaPd After: https://msvc.godbolt.org/z/vWYjazWGr, https://gcc.godbolt.org/z/hdsvTq9nE Fixes: QTBUG-102246 Pick-to: 6.2 6.3 Change-Id: I29f1c141c0f7436393d9fffd16e2bbbf4c0fe54d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject_p.h')
-rw-r--r--src/corelib/kernel/qobject_p.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index d98c7065f0..c77bdeff0d 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -319,11 +319,14 @@ public:
SignalVector *newVector = reinterpret_cast<SignalVector *>(malloc(sizeof(SignalVector) + (size + 1) * sizeof(ConnectionList)));
int start = -1;
if (vector) {
+ // not (yet) existing trait:
+ //static_assert(std::is_relocatable_v<SignalVector>);
+ //static_assert(std::is_relocatable_v<ConnectionList>);
memcpy(newVector, vector, sizeof(SignalVector) + (vector->allocated + 1) * sizeof(ConnectionList));
start = vector->count();
}
for (int i = start; i < int(size); ++i)
- newVector->at(i) = ConnectionList();
+ new (&newVector->at(i)) ConnectionList();
newVector->next = nullptr;
newVector->allocated = size;