Size of types should be queryable in interface
Opened this issue · 3 comments
Tracking item for adding size information for types. This includes size information of primitives and size computation of user defined types. Alignment may also have to be considered.
This could be available as part of the lexicon or some combination of the lexicon and auxiliary free functions.
Probably this is evident, but we should also be able to query offsets of fields for classes. (And this might be sufficient to calculate paddings. )
Information such as offsetof
and friends are properties of the compiler's layout algorithms and other environmental parameters. I would suggest to separate that from characteristics such as sizeof
and alignof
of builtin types.
Certain builtin types (like double
) have natural alignment (e.g. 8) that is different from when they are used as type of non-static data members of structures (e.g. 4). See GCC's option -malign-double
and the rationale.
I suppose one way to account for this is to say that the alignment of the field is that of that subobject, not necessarily the natural alignment of the type even if the declaration of such a field does not contain alignas
.