From 1961e3f93d8feb4eea64c548e038598991150479 Mon Sep 17 00:00:00 2001 From: Luke Zhu Date: Sun, 27 Oct 2024 01:15:41 +0000 Subject: [PATCH] make struct size the size of all members I am unsure about this code, but the += seemed a bit fishy, so I assume the code for determining struct size should be summing up the sizes of all struct members. --- parse.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index 6acaeb8c..e554097c 100644 --- a/parse.c +++ b/parse.c @@ -1300,10 +1300,11 @@ static Initializer *initializer(Token **rest, Token *tok, Type *ty, Type **new_t ty = copy_struct_type(ty); Member *mem = ty->members; - while (mem->next) + while (mem->next) { mem = mem->next; - mem->ty = init->children[mem->idx]->ty; - ty->size += mem->ty->size; + mem->ty = init->children[mem->idx]->ty; + ty->size += mem->ty->size; + } *new_ty = ty; return init;