[Development] What's Q_PRIMITIVE_TYPE for?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Wed Nov 11 12:04:46 CET 2020

Il 10/11/20 20:00, Giuseppe D'Angelo via Development ha scritto:
> Yes, sure. But also something like QStringView, which is (char16_t*,
> qsizetype), is a primitive type (assuming all-0 representation for a
> null pointer).

Just to insist on this: there are no guarantees coming from the Standard 
that null pointers are all 0 bits. The only guarantees, if any, come 
from our platforms / platforms' ABI.

For instance , on the Itanium ABI:

* struct A { int a, b; }; can be value-initialized with 0 bits
* struct B { int *ptr; }; can be value-initialized with 0 bits
* struct C { int A::* ptr; }; *CANNOT BE VALUE-INITIALIZED* with 0 bits.

Because null pointers to data members are initialized with the value 
"-1". https://gcc.godbolt.org/z/3aWWYx

So, one has to be extremely careful with marking something as primitive, 
and I don't think we have any tests regarding this (but we don't run on 
any platform with "fancy" null pointers either, I guess).

Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20201111/663fb1b5/attachment.bin>

More information about the Development mailing list