harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4a99171eb347382a7aeec4191f47135da9604009
parent 430723518f8250e69281f6837e21183460521e53
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Mar 2021 09:21:35 -0500

type_store: add sanity checks around struct fields

Diffstat:
Msrc/type_store.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/type_store.c b/src/type_store.c @@ -145,6 +145,7 @@ struct_insert_field(struct type_store *store, struct struct_field **fields, field->name = strdup(atype->field.name); field->type = type_store_lookup_atype(store, atype->field.type); + assert(field->type->size != SIZE_UNDEFINED); if (atype->offset) { *ccompat = false; @@ -172,6 +173,11 @@ struct_insert_field(struct type_store *store, struct struct_field **fields, *usize = field->type->size > *usize ? field->type->size : *usize; } *align = field->type->align > *align ? field->type->align : *align; + + if (!atype->offset) { + assert(field->offset % field->type->align == 0); + assert(field->offset % *align == 0); + } } static void