dimanche 5 février 2023

C++ standard for member offsets of standard layout struct

Does the C++11 standard guarantee that all compilers will choose the same memory offsets for all members in a given standard layout struct, assuming all members have guaranteed sizes (e.g. int32_t instead of int)?

That is, for a given member in a standard layout struct, does C++11 guarantee that offsetof will give the same value across all compilers?

If so, is there any specification of what that value would be, e.g. as a function of size, alignment, and order of the struct members?

Aucun commentaire:

Enregistrer un commentaire