On 01/03/2021 11:45, Fabian Kosmale wrote:
currently we promise that if for a type its QMetaType does not have the 
NeedsConstruction flag set, it can be initialized with memzero. We set that 
flag if the type is complex according to QTypeInfo. However, after the 
discussion 
inhttps://lists.qt-project.org/pipermail/development/2020-November/040546.html, 
primitive types are not complex, but only guarantee that they can be memcpyed 
not memzeroed. Therefore either the implementation or the documentation of 
NeedsConstruction needs  to change (note that Qt itself does not use that flag 
anywhere as far as I can tell).
But which of those two options should we choose? What are the actual use-cases 
of that flag anyway?

Well, one of the outcomes of that discussion is that we can't at the same time

- assume that trivial types are PRIMITIVE, and
- zero-initialize PRIMITIVE types

because of things like pointers to data members. So we've decided to ditch zero-initialization and go for value-initializing everything, pushing the "problem" of replacing a loop of value-initializations with a corresponding memset(0).

I guess that the NeedsConstruction flag has not been updated; FWIW, it could be ditched entirely? All types are value initialized, whether it's in containers, in QVariants and so on.

Thanks,
--
Giuseppe D'Angelo | [email protected] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to