Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of types should be queryable in interface #97

Open
d-winsor opened this issue Dec 8, 2020 · 3 comments
Open

Size of types should be queryable in interface #97

d-winsor opened this issue Dec 8, 2020 · 3 comments
Assignees

Comments

@d-winsor
Copy link
Contributor

d-winsor commented Dec 8, 2020

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.

@Xazax-hun
Copy link
Contributor

Xazax-hun commented Dec 9, 2020

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. )

@GabrielDosReis
Copy link
Owner

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.

@GabrielDosReis GabrielDosReis self-assigned this Jan 15, 2021
@GabrielDosReis
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants